chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.06k stars 1.19k forks source link

Throw `ERRBadAwait` instead of `ERRnoSemic` if applicable #6955

Closed ShortDevelopment closed 2 months ago

ShortDevelopment commented 9 months ago

Issue

It might happen that a developer forgets to declare a function as async but still uses await as a keyword. In this case the CC parser will just display a ERRnoSemic as seen in #5103.

Changes

According to the proposal of @rhuanjl in https://github.com/chakra-core/ChakraCore/issues/5103#issuecomment-612573281 the parser now checks if the previous token was a tkID equal to await. In that case the parser throws a ERRBadAwait.


Fixes #5103

rhuanjl commented 9 months ago

Thanks for the contribution, it would be nice to see this changed.

Unfortunately the test fails look legitimate to me, (as in this appears to have introduced a new bug) if you can work out what's gone wrong that would be great, if not I'll try and investigate on Monday or Tuesday.

ShortDevelopment commented 7 months ago

@rhuanjl Comparing the CI output of a PR with "no code" and mine it seems like the failing tests might be unrelated to the changes in this PR

Both failed with

Total: passed 1382, failed 630
rhuanjl commented 2 months ago

@rhuanjl Comparing the CI output of a PR with "no code" and mine it seems like the failing tests might be unrelated to the changes in this PR

Both failed with

Total: passed 1382, failed 630

Seems you were right, CI is sorted now, this PR looks good though I'd ideally not like to introduce the TS comments to our codebase.

ShortDevelopment commented 2 months ago

@rhuanjl Comments are removed

Seems you were right, CI is sorted now

It's still a bit scary to have CI failing randomly

rhuanjl commented 2 months ago

@rhuanjl Comments are removed

Seems you were right, CI is sorted now

It's still a bit scary to have CI failing randomly

I think it was an issue ages ago that's been fixed in the meantime...

I'll gain additional confidence of that if it passes again now having already passed once before you removed the comments.