Giter VIP home page Giter VIP logo

Comments (5)

kzc avatar kzc commented on August 18, 2024

@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.

kzc avatar kzc commented on August 18, 2024

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.

phazei avatar phazei commented on August 18, 2024

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.

kzc avatar kzc commented on August 18, 2024

@phazei Thanks for the repro.

from terser.

kzc avatar kzc commented on August 18, 2024

uglify-js has the same problem. Reported upstream: mishoo/UglifyJS#3192

from terser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.