You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assertion when scanning invalid numeric literal after multi-unit characters
We can throw an error when scanning numeric literals. If the numeric literal is preceeded by multi-unit whitespace (eaten as part of the numeric literal token) we will count up those multi-units into Scanner::m_cMultiUnits. However, if the numeric literal ends up throwing, we should reset the multi-unit counter in scanner to whatever it was before we started to scan the whitespace and numeric literal token. If we don't reset the multi-unit counter, the character offset for the error object will be wrong and debug build will assert.
Fixes#5571
Copy file name to clipboardExpand all lines: test/Scanner/NumericLiteralSuffix.js
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,14 @@ var tests = [
82
82
eval("\u2028var\u2028x\u2028=\u20281234\u2028; result = x;");
83
83
assert.areEqual(1234,result,"Mutli-unit whitespace after numeric literal does not affect literal value");
84
84
}
85
+
},
86
+
{
87
+
name: "Multi-unit count updated in the middle of a token",
88
+
body: function(){
89
+
assert.throws(()=>eval('\u20091a'),SyntaxError,'Multi-unit whitespace followed by numeric literal followed by identifier','Unexpected identifier after numeric literal');
90
+
assert.throws(()=>eval('\u20091\\u0065'),SyntaxError,'Multi-unit whitespace followed by numeric literal followed by unicode escape sequence','Unexpected identifier after numeric literal');
91
+
assert.throws(()=>eval('\u20090o1239'),SyntaxError,'Multi-unit whitespace followed by invalid octal numeric literal','Invalid number');
0 commit comments