Skip to content
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

ES6 default parameters cause two write references #72

Open
bakkot opened this issue Jul 7, 2015 · 2 comments
Open

ES6 default parameters cause two write references #72

bakkot opened this issue Jul 7, 2015 · 2 comments

Comments

@bakkot
Copy link

bakkot commented Jul 7, 2015

(@michaelficarra)

See for example this test:

expect(scope.references[1].identifier.name).to.equal 'c'
expect(scope.references[1].isWrite()).to.be.true
expect(scope.references[1].writeExpr.name).to.equal 'e'
expect(scope.references[1].partial).to.be.true
expect(scope.references[1].resolved).to.equal scope.variables[2]
expect(scope.references[2].identifier.name).to.equal 'c'
expect(scope.references[2].isWrite()).to.be.true

Note that there are two references with name c and isWrite() true: that is, two write references to c. This despite the fact that c will be written precisely once by the sample code. This is especially confusing if you're looking at const-correctness.

Is this intentional? If so, what's the reasoning behind it?

@michaelficarra
Copy link
Member

Ping @mysticatea, author of 23bb40b which added the referenced tests.

@mysticatea
Copy link
Contributor

escope has been making a writable reference for variable initializers, so I treated default parameters and default values of destructuring as same as that.
Currently, references for initializers, default parameters, and default values are have a property init as true.

(Thanks @michaelficarra)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants