Skip to content

Commit 6622220

Browse files
committed
Array parse fix
Do not allow arrays without comma between values (HaxeFoundation#138)
1 parent ca0599b commit 6622220

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hscript/Parser.hx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,21 @@ class Parser {
481481
case TBkOpen:
482482
var a = [];
483483
tk = token();
484+
var first:Bool = true;
484485
while( tk != TBkClose && (!resumeErrors || tk != TEof) ) {
486+
if(!first) {
487+
if(tk != TComma)
488+
unexpected(tk);
489+
else
490+
tk = token();
491+
}
492+
first = false;
485493
push(tk);
486494
var oldoo = disableOrOp;
487495
disableOrOp = false;
488496
a.push(parseExpr());
489497
disableOrOp = oldoo;
490498
tk = token();
491-
if( tk == TComma )
492-
tk = token();
493499
}
494500
if( a.length == 1 && a[0] != null ) // What is this for???
495501
switch( expr(a[0]) ) {

0 commit comments

Comments
 (0)