diff --git a/ChangeLog b/ChangeLog index e730364d30..5c0de5a968 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ Bangle.js2: Allow 2 central links at once Fix `if (0);"test"||fail()` 2v19 regression - strings after if(0) didn't get interpreted Ensure eval("1;;;")==1 - eval("1;")==1 before, but not eval("1;;") + Ensure AssignmentExpr returns the value of LHS, not the LHS. `(a=2)=3` now fails (as per spec) + Ensure default args for arrow functions fail with error `(a,b=3)=>a+b` now fails (until default args get added) 2v19 : Fix Object.values/entries for numeric keys after 2v18 regression (fix #2375) nRF52: for SD>5 use static buffers for advertising and scan response data (#2367) diff --git a/src/jsparse.c b/src/jsparse.c index caac1b4cb4..d2c0964157 100644 --- a/src/jsparse.c +++ b/src/jsparse.c @@ -2205,6 +2205,7 @@ NO_INLINE JsVar *__jspeAssignmentExpression(JsVar *lhs) { } } jsvUnLock(rhs); + lhs = jsvSkipNameAndUnLock(lhs); } return lhs; } @@ -2318,6 +2319,7 @@ NO_INLINE JsVar *jspeBlockOrStatement() { return 0; } else { JsVar *v = jspeStatement(); + if (lex->tk==';') JSP_ASSERT_MATCH(';'); return v; } } @@ -2329,7 +2331,6 @@ NO_INLINE JsVar *jspParse() { while (!JSP_SHOULDNT_PARSE && lex->tk != LEX_EOF) { jsvUnLock(v); v = jspeBlockOrStatement(); - while (lex->tk==';') JSP_ASSERT_MATCH(';'); jsvCheckReferenceError(v); } return v; @@ -2410,9 +2411,7 @@ NO_INLINE JsVar *jspeStatementIf() { JSP_SAVE_EXECUTE(); if (!cond) jspSetNoExecute(); JsExecFlags hasError = 0; - JsVar *a = 0; - if (lex->tk!=';') - a = jspeBlockOrStatement(); + JsVar *a = jspeBlockOrStatement(); hasError |= execInfo.execute&EXEC_ERROR_MASK; if (!cond) { jsvUnLock(a); @@ -2421,16 +2420,11 @@ NO_INLINE JsVar *jspeStatementIf() { } else { result = a; } - /* We must manually parse ';' here, because if we did it when execInfo.execute==false (eg `if(0);`) - then if a String comes straight after it wouldn't have been interpreted */ - if (lex->tk==';') JSP_ASSERT_MATCH(';'); if (lex->tk==LEX_R_ELSE) { JSP_ASSERT_MATCH(LEX_R_ELSE); JSP_SAVE_EXECUTE(); if (cond) jspSetNoExecute(); - JsVar *a = 0; - if (lex->tk!=';') - a = jspeBlockOrStatement(); + JsVar *a = jspeBlockOrStatement(); hasError |= execInfo.execute&EXEC_ERROR_MASK; if (cond) { jsvUnLock(a);