File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
MoonSharp.Interpreter/Tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ internal static Expression SimpleExp(ScriptLoadingContext lcontext)
172
172
case TokenType . Number :
173
173
case TokenType . Number_Hex :
174
174
case TokenType . Number_HexFloat :
175
- case TokenType . String :
175
+ case TokenType . String when lcontext . Syntax != ScriptSyntax . CLike :
176
176
case TokenType . String_Long :
177
177
case TokenType . Nil :
178
178
case TokenType . True :
@@ -305,6 +305,8 @@ private static Expression PrefixExp(ScriptLoadingContext lcontext)
305
305
Token T = lcontext . Lexer . Current ;
306
306
switch ( T . Type )
307
307
{
308
+ case TokenType . String when lcontext . Syntax == ScriptSyntax . CLike :
309
+ return new LiteralExpression ( lcontext , T ) ;
308
310
case TokenType . Brk_Open_Round :
309
311
lcontext . Lexer . Next ( ) ;
310
312
Expression e = Expr ( lcontext ) ;
Original file line number Diff line number Diff line change @@ -418,6 +418,14 @@ public void LengthProperty()
418
418
" , s => s . Options . Syntax = ScriptSyntax . CLike ) ;
419
419
}
420
420
421
+ [ Test ]
422
+ public void LengthStringLiteral ( )
423
+ {
424
+ TestScript . Run ( @"
425
+ assert.areequal(5, 'hello'.length);
426
+ " , s => s . Options . Syntax = ScriptSyntax . CLike ) ;
427
+ }
428
+
421
429
[ Test ]
422
430
public void LengthPropertyReadonly ( )
423
431
{
You can’t perform that action at this time.
0 commit comments