diff --git a/acorn.js b/acorn.js index 582d3b3938..3aea6dafa2 100644 --- a/acorn.js +++ b/acorn.js @@ -643,7 +643,7 @@ if (isFloat || input.charAt(tokPos) === ".") { var next = input.charAt(++tokPos); if (next === "-" || next === "+") ++tokPos; - if (readInt(10) === null) raise(start, "Invalid number"); + if (readInt(10) === null && ch === ".") raise(start, "Invalid number"); isFloat = true; } if (/e/i.test(input.charAt(tokPos))) { diff --git a/index.html b/index.html index a5ed4ad7a5..bdb451f0b2 100644 --- a/index.html +++ b/index.html @@ -417,7 +417,7 @@ will return null unless the integer has exactly len di if (isFloat || input.charAt(tokPos) === ".") { var next = input.charAt(++tokPos); if (next === "-" || next === "+") ++tokPos; - if (readInt(10) === null) raise(start, "Invalid number"); + if (readInt(10) === null && ch === ".") raise(start, "Invalid number"); isFloat = true; } if (/e/i.test(input.charAt(tokPos))) { diff --git a/test/tests.js b/test/tests.js index a34b7698b2..5ca91c95af 100644 --- a/test/tests.js +++ b/test/tests.js @@ -25981,6 +25981,50 @@ test("(function () { 'use strict'; '\0'; }())", { ] }); +test("123..toString(10)", { + type: "Program", + start: 0, + end: 17, + body: [ + { + type: "ExpressionStatement", + start: 0, + end: 17, + expression: { + type: "CallExpression", + start: 0, + callee: { + type: "MemberExpression", + start: 0, + object: { + type: "Literal", + start: 0, + end: 4, + value: 123 + }, + property: { + type: "Identifier", + start: 5, + end: 13, + name: "toString" + }, + computed: false, + end: 13 + }, + arguments: [ + { + type: "Literal", + start: 14, + end: 16, + value: 10 + } + ], + end: 17 + } + } + ] +}); + // Failure tests testFail("{",