From 8db9350f68c62442411aab98cda00631c91ebd3d Mon Sep 17 00:00:00 2001 From: Jeremy Faivre Date: Fri, 7 Mar 2025 16:19:24 +0100 Subject: [PATCH] Do not allow arrays without comma between values --- hscript/Parser.hx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index f71bb59..06e4ef9 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -446,12 +446,18 @@ class Parser { case TBkOpen: var a = new Array(); tk = token(); + var first = true; while( tk != TBkClose && (!resumeErrors || tk != TEof) ) { + if (!first) { + if (tk != TComma) + unexpected(tk); + else + tk = token(); + } + first = false; push(tk); a.push(parseExpr()); tk = token(); - if( tk == TComma ) - tk = token(); } if( a.length == 1 && a[0] != null ) switch( expr(a[0]) ) {