-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 option to throw error on obvious runtime errors #1500
Comments
$ node
> try{console.log(function(){var a;const a=2;return a}())}catch(e){console.log("E!",e)}
try{console.log(function(){var a;const a=2;return a}())}catch(e){console.log("E!",e)}
^
SyntaxError: Identifier 'a' has already been declared
> try{console.log(function(){a = 1;const a=2;return a}())}catch(e){console.log("E!",e)}
E! ReferenceError: a is not defined
at repl:1:30 |
$ node
> "use strict";try{"abc".in=1}catch(e){console.error("E", e)}
E TypeError: Cannot create property 'in' on string 'abc'
at repl:1:26
at ContextifyScript.Script.runInThisContext (vm.js:23:33) |
After #1910 the If we were to introduce say I guess we should have that flag off by default, and serve as some form of extra sanity checks? |
The original motivation for this issue was that an optimization was ignoring the |
The new $ echo 'function f(){const a=1;a=2;return a}' | bin/uglifyjs -c reduce_vars=0
function f(){return 2}
|
I consider that a regression in
The code emitted above, although transformed, would preserve the error of the assignment to |
Indeed that's odd - $ bin/uglifyjs -V
uglify-js 2.8.23
$ echo 'function f(){const a=1;a=2;return a}' | bin/uglifyjs -c reduce_vars=0,evaluate=0
function f(){return 2} I'll try and figure this out in a bit when I'm done with #1910 & #1916 |
Ah, looking in the wrong place for
So I think if I add the extra checks for |
@alexlamsl I think this issue can be closed now that you've addressed the |
Cool 😎 |
From #1497 (comment)
The text was updated successfully, but these errors were encountered: