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
{{ message }}
Repository navigation
Binding identifier should care about await/yield contextΒ #44459
asyncfunctionfoo(){varawait=1;// should be an error, but not}asyncfunctionbar(){letawait=2;// error}function*foo1(){varyield=1;// should be an error, but not}function*bar1(){letyield=2;// error}
π Actual behavior
BindingIdentifier in await/yield with var keyword does not throw errors.
The problem is that let await errors are issued in the parser and var await errors are issued in the binder. Syntax errors block reporting of semantic errors.
The parse errors for let await are horrible, so the right fix is to allow it in the parser and issue the same grammar error as for var await in the binder.
Note that this will make the error disappear in plain JS files for now. I hope to fix that soon.
Sorry, it's a new term. 'plain JS file' means a JS file that is part of a compilation, but is not reporting semantic errors. That is, checkJS is not turned on OR explicitly off, and the file doesn't have // @ts-check or // @ts-no-check in it. Plain JS files report syntax errors but not semantic errors, so moving a parser error to a grammar error makes it disappear. However, I'm planning to turn on grammar errors for plain JS files in the next release.
Activity
sandersn commentedon Jun 18, 2021
The problem is that
let awaiterrors are issued in the parser andvar awaiterrors are issued in the binder. Syntax errors block reporting of semantic errors.The parse errors for
let awaitare horrible, so the right fix is to allow it in the parser and issue the same grammar error as forvar awaitin the binder.Note that this will make the error disappear in plain JS files for now. I hope to fix that soon.
Kingwl commentedon Jun 22, 2021
Sorry, I'm not 100% sure what your means. Does
plain JS filesmeans js files we emitted?sandersn commentedon Jun 22, 2021
Sorry, it's a new term. 'plain JS file' means a JS file that is part of a compilation, but is not reporting semantic errors. That is, checkJS is not turned on OR explicitly off, and the file doesn't have
// @ts-checkor// @ts-no-checkin it. Plain JS files report syntax errors but not semantic errors, so moving a parser error to a grammar error makes it disappear. However, I'm planning to turn on grammar errors for plain JS files in the next release.