Giter VIP home page Giter VIP logo

Comments (4)

evanw avatar evanw commented on May 26, 2024

This comment is relevant:

// Lower each argument individually instead of lowering all arguments
// together. There is a correctness tradeoff here around default values
// for function arguments, with no right answer.
//
// Lowering all arguments together will preserve the order of side effects
// for default values, but will mess up their scope:
//
// // Side effect order: a(), b(), c()
// function foo([{[a()]: w, ...x}, y = b()], z = c()) {}
//
// // Side effect order is correct but scope is wrong
// function foo(_a, _b) {
// var [[{[a()]: w, ...x}, y = b()], z = c()] = [_a, _b]
// }
//
// Lowering each argument individually will preserve the scope for default
// values that don't contain object rest binding patterns, but will mess up
// the side effect order:
//
// // Side effect order: a(), b(), c()
// function foo([{[a()]: w, ...x}, y = b()], z = c()) {}
//
// // Side effect order is wrong but scope for c() is correct
// function foo(_a, z = c()) {
// var [{[a()]: w, ...x}, y = b()] = _a
// }
//
// This transform chooses to lower each argument individually with the
// thinking that perhaps scope matters more in real-world code than side
// effect order.

from esbuild.

magic-akari avatar magic-akari commented on May 26, 2024

esbuild considers scope to be more important than side effect order.
However, in this example, the reference to aa is still incorrect.

from esbuild.

magic-akari avatar magic-akari commented on May 26, 2024

Thank you for the clear comments in esbuild.
This issue was actually discovered when I was reading the esbuild source code.
However, I feel that it might not be worth solving, or it might be unsolvable. I'm just bringing it up here for the record.

from esbuild.

evanw avatar evanw commented on May 26, 2024

Yes, makes sense. Thanks for the report. When I get the time to think about this, I'll have to load this back in my head to figure out what to do about it, if anything. That comment (and any relevant surrounding commit logs from then) will be a good starting point for me.

from esbuild.

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.