Comments (5)
@phazei Cannot reproduce an incorrect result. Could you add one or more console.log()
statements to your example to demonstrate the program producing a wrong result when minified?
from terser.
Here's a different test case that produces an incorrect result when minified:
$ bin/uglifyjs -V
terser 3.7.6
$ cat issue-t58.js
function f(x){
console.log(x, arguments[0]);
x = 2;
console.log(x, arguments[0]);
arguments[0] = 3;
console.log(x, arguments[0]);
}
f();
f(1);
expected:
$ cat issue-t58.js | node
undefined undefined
2 undefined
2 3
1 1
2 2
3 3
actual:
$ cat issue-t58.js | bin/uglifyjs -bc | node
undefined undefined
2 2
2 2
1 1
2 2
3 3
Bug workaround - disable the arguments
compress option:
$ cat issue-t58.js | bin/uglifyjs -bc arguments=false | node
undefined undefined
2 undefined
2 3
1 1
2 2
3 3
We may elect to have the arguments
option disabled in terser
by default as well.
I'd still like to see the example in the top post altered to produce incorrect output when run in the event that it is a different issue.
from terser.
Turns out "use strict"; is necessary to provide the proper issue error I found out after a bit more testing.
I've updated the code in the op to reflect that as well as console.log'ing
Also just a note: I was using gulp-uglify which was using uglify-js 2.8.29 and that didn't have the issue. I just recently converted to gulp-uglify-es which uses the latest terser version. While switching over only required changing the 'require()' package name, this seems to be the only issue that arose.
from terser.
@phazei Thanks for the repro.
from terser.
uglify-js
has the same problem. Reported upstream: mishoo/UglifyJS#3192
from terser.
Related Issues (20)
- Use without NPM HOT 1
- Private fields, `in` and precedence (?) HOT 1
- Never use unsafe_methods
- renames arrow function declaration despite `keep_fnames: true` HOT 2
- [Feature request] ability to declare a static block as pure HOT 3
- When the compression is enabled, used variables are dropped. HOT 3
- [Feature request] nameCache and __MANGLE_PROP__ overlap HOT 5
- preserve_annotations changes position of `/* #__PURE__ */` comments in function calls HOT 1
- Support new import attributes "with" syntax. HOT 6
- Babel transpiled ES6 class is not working after mangling with terser HOT 3
- reserved is not a supported option HOT 1
- Replace new BigInt("0") with 0n for ecma: 2020+ HOT 1
- try/catch block that can't possibly throw should be unwrapped
- IIFE Parameter is being removed and causes code to break HOT 3
- AWS Pipe line deploy got this error
- [Feature] Support @pure in JSdoc just like `@__PURE__`
- Drop console.assert() statements with always true assertion HOT 1
- Not sure what to call this. Javascript destructuring? HOT 2
- Issue in Minification in v5.31.4 HOT 2
- 5.31.4 is dropping base classes when there are sub classes that extend the base class. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terser.