shapesecurity / shift-parser-js

ECMAScript parser that produces a Shift format AST
http://shift-ast.org/parser.html
Apache License 2.0
249 stars 28 forks source link

Shift Parser throws exception in the parse Methods in "pass" scripts #311

Closed Shilpi3 closed 7 years ago

Shilpi3 commented 7 years ago

[pass/1012.script.js] for (let {a: b = let};;) {}

[pass/995.script.js] for (let [a = let];;) {}

Expected: No Exception for pass scripts Actual: Both the above scripts throws exception

` /Users/u326/wco-modules/shift-parser-js/dist/parser.js:748 throw this.createError(_errors.ErrorMessages.UNINITIALIZED_BINDINGPATTERN_IN_FOR_INIT); ^

Error: [1:20]: Binding pattern appears without initializer in for statement init at new JsError (/Users/u326/wco-modules/shift-parser-js/dist/tokenizer.js:163:104) at GenericParser.createError (/Users/u326/wco-modules/shift-parser-js/dist/tokenizer.js:285:14) at GenericParser.parseForStatement (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:748:26) at GenericParser.parseStatementHelper (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:582:23) at GenericParser.isolateCoverGrammar (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:1067:23) at GenericParser.parseStatement (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:556:23) at GenericParser.parseStatementListItem (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:548:25) at GenericParser.parseBody (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:290:61) at GenericParser.parseScript (/Users/u326/wco-modules/shift-parser-js/dist/parser.js:244:30) at parse (/Users/u326/wco-modules/shift-parser-js/dist/index.js:114:43) at parse (/Users/u326/wco-modules/shift-parser-js/test/test262/errors.js:9:41) at Object. (/Users/u326/wco-modules/shift-parser-js/test/test262/errors.js:12:13) at Module._compile (module.js:573:32) at Object.Module._extensions..js (module.js:582:10) at Module.load (module.js:490:32) at tryModuleLoad (module.js:449:12) at Function.Module._load (module.js:441:3) at Module.require (module.js:500:17) at require (internal/module.js:20:19) at /Users/u326/wco-modules/shift-parser-js/node_modules/mocha/lib/mocha.js:216:27 at Array.forEach (native) at Mocha.loadFiles (/Users/u326/wco-modules/shift-parser-js/node_modules/mocha/lib/mocha.js:213:14) at Mocha.run (/Users/u326/wco-modules/shift-parser-js/node_modules/mocha/lib/mocha.js:453:10) at Object. (/Users/u326/wco-modules/shift-parser-js/node_modules/mocha/bin/_mocha:393:18) at Module._compile (module.js:573:32) at Object.Module._extensions..js (module.js:582:10) `

Sample Scripts

michaelficarra commented 7 years ago

1012:

for (let {a: b = let};;) {}

970:

function a([], []) {'use strict';}

995:

for (let [a = let];;) {}

970 appears to be an invalid test. The other two appear to be occurrences of the same bug.

bakkot commented 7 years ago

They're all invalid tests - opened https://github.com/tc39/test262-parser-tests/issues/8

Specifically, 995 and 1012 have uninitialized destructuring patterns.