New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[[FIX]] Tolerate late definition of async function #3618
Conversation
Thanks for the patch! This is definitely an oversight, and I'm grateful you've stepped up to fix it. Since "async identifier": function (test) {
var src = [
"(function() {",
" return f(4);",
" async();",
"}());"
];
TestRun(test)
.addError(3, 3, "Unreachable 'async' after 'return'.")
.test(src, { esversion: 8, latedef: "nofunc" });
test.done();
} Now, disambiguating Does that sound right to you? Would you be up for addressing it? |
86d212d
to
e00e590
Compare
How about now? |
Much closer! Your expectation about the grammar is correct: a newline between However, the latest iteration of suppresses the warning when it encounters the sequence " "async asi": function (test) {
var src = [
"(function() {",
" return f(4);",
" async",
" function f(p) {",
" return p + 1;",
" }",
"}());"
];
TestRun(test)
.addError(3, 3, "Unreachable 'async' after 'return'.")
.test(src, { esversion: 8, latedef: "nofunc", asi: true, expr: true });
test.done();
}, (I added in the Does that make sense to you? If so, I think we may be able to simplify the implementation--we only want to suppress the warning if we see |
We used to mark `async function` as unreachable instead of treating it as any other late function definition. This change makes jshint react to `async` keyword in the same way as it reacted to `function` keyword.
e00e590
to
7e3cbcb
Compare
I added the recommended test and removed the code that used to skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Thanks so much for sticking with this; I'm happy to have your help :)
I'll publish a patch release including this fix within the week.
We just released this via JSHint version 2.13.5. Thanks again! |
We used to mark
async function
as unreachable instead of treating it as any other late function definition. This change makes jshint react toasync
keyword in the same way as it reacted tofunction
keyword.