-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
new Map(wrong_iterable) swallow TypeError in file scripts #16856
Comments
@nodejs/v8, Is it an upstream bug? |
@vsemozhetbyt Doesn't look like it |
@joyeecheung Maybe we should also check with the module wrapper to be sure (compare #15386): > (function (exports, require, module, __filename, __dirname) { new Map('a'); })();
TypeError: Iterator value a is not an entry object
at new Map (<anonymous>)
at repl:1:63 |
@vsemozhetbyt d8 still throws with the wrapper
|
I can reproduce with the latest canary ( |
Looks like some kind of crash. 'use strict';
console.log('a');
try {
console.log(new Map('a'));
} catch (err) {
console.log(err);
}
console.log('b'); prints 'use strict';
console.log('a');
console.log(new Map('a'));
console.log('b'); only prints |
cc @gsathya |
@bmeurer Should not this be an early error at the parsing time? |
It's correct syntax. Why would it be an early error? |
@hashseed We can know that a string is not an appropriate iterable in all such cases? |
At parse time you can't know what |
Interestingly, with the following code
|
The upcoming fix is here: https://chromium-review.googlesource.com/c/v8/v8/+/758372 |
Fix has landed upstream. |
Original commit message: [map] Fix map constructor to correctly throw. We need to throw before rethrowing, otherwise the exception does not trigger a debugger event and is not reported if uncaught. R=gsathya@chromium.org, jgruber@chromium.org Bug: v8:7047 Change-Id: I7ce0253883a21d6059e4e0ed0fc56dc55a0dcba6 Reviewed-on: https://chromium-review.googlesource.com/758372 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{nodejs#49237} Fixes: nodejs#16856
Original commit message: [map] Fix map constructor to correctly throw. We need to throw before rethrowing, otherwise the exception does not trigger a debugger event and is not reported if uncaught. R=gsathya@chromium.org, jgruber@chromium.org Bug: v8:7047 Change-Id: I7ce0253883a21d6059e4e0ed0fc56dc55a0dcba6 Reviewed-on: https://chromium-review.googlesource.com/758372 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#49237} PR-URL: #16897 Fixes: #16856 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This only happens with a file script. In the REPL,
new Map('a')
throwsTypeError
in all these versions.The text was updated successfully, but these errors were encountered: