You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Assigning to rest parameter fails as variable is not defined #2091
Essentially, I am assigning to the args variable but because I'm not passing the args variable anywhere, all references to it are being optimised to reference arguments directly.
The transpiled code contains a variable declartion for _ref2 but not for args:
In fact, it's even using arguments in the last part of the ternary expression even though that's not referencing the flattened array as returned by concat.
Although I don't know the extent of the repercussions, re compiler optimizations, the assignment of arguments to args will have. Should I just accept I can't do this in a one-liner and declare a different variable?
The direct arguments usage optimization was added in 4.6.0 (based on the change log), so it was probably that, unless this was introduced after the original optimization logic was.
@RamIdeas Thanks for the info. That makes it sound like it probably changed in a recent release of babel-core. I'm currently working with this reduced test case:
I've been trying to figure this out and it's very difficult because the code is so dense and so sparsely documented, and the call stacks are so gnarly.
So far it seems to me that the key thing is that this ReferencedIdentifier method doesn't get invoked, so an item isn't pushed to state.references. I think this code in isReferenced() may be important, but I haven't figured the situation out yet. I actually just realized that I think I was misreading the comment on that code until now and thought it didn't match the implementation. Maybe when I look at it again the comment will inform my debugging better.
This is useful as you can't just arbitrarily visit all Identifiers as then you're visiting:
object.IDENTIFIER;varobject={IDENTIFIER: ""};
and you can't make many assumptions.
As for virtual types, they're specified in this file. Virtual types are just some way of conditionally considering a node to be of a specific "virtual" type. This is handy as it means you can have more generic standard node types that then become more fine grained through virtual types.
Oh wait, you were asking if those definitions were correct. Yeah, that's basically it. As for the origin of those terms, BindingIdentifier is used in the ECMAScript specification grammar definitions. Dunno where ReferenceIdentifier comes from, I don't think I made it up.
This is useful as you can't just arbitrarily visit all Identifiers as then you're visiting:
...
and you can't make many assumptions.
...
As for virtual types...
Yeah that makes sense. I'd seen that file with the virtual types, just hadn't had the chance to figure out what they represent or how they're implemented yet. Thanks for the description.
Oh wait, you were asking if those definitions were correct. Yeah, that's basically it.
Ok, thanks.
As for the origin of those terms, BindingIdentifier is used in the ECMAScript specification grammar definitions. Dunno where ReferenceIdentifier comes from, I don't think I made it up.
Ok, I was wondering because I see BindingIdentifier in the ES spec, but it appears to represent something different here. I think that in the spec these are not BindingIdentifier but rather IdentifierReference:
I haven't had the chance to study how these virtual types are used enough to know if that's relevant here.
I don't know if IdentifierReference inspired the name ReferencedIdentifier, but they're obviously very similar and I think used somewhat similarly. Maybe you did make up ReferencedIdentifier? I get 1 result for:
Activity
jmm commentedon Jul 27, 2015
Seems like a bug to me -- checking it out. Do you know what the respective versions are where it worked / stopped working?
RamIdeas commentedon Jul 27, 2015
Sorry, I've looked through my commits but the version in my
package.jsonhas been the same for a while.But I run
npm outdatedabout once a week or so, and read through CHANGELOGs before deciding whether to runnpm update.I should add, I cannot confirm whether this was transpiled correctly before... Just that it did not throw an error.
i.e.
_Object$assign.applymay have been passedargumentsorargs, I'm not sure. Butargswas defined.loganfsmyth commentedon Jul 27, 2015
The direct
argumentsusage optimization was added in 4.6.0 (based on the change log), so it was probably that, unless this was introduced after the original optimization logic was.RamIdeas commentedon Jul 27, 2015
I checked-in the function 2 weeks ago on July 13th
loganfsmyth commentedon Jul 27, 2015
Yeah, thinking on it more, I think that changelog entry is for something else, my mistake. There have been more recent changes to those transformers.
jmm commentedon Jul 27, 2015
@RamIdeas Thanks for the info. That makes it sound like it probably changed in a recent release of
babel-core. I'm currently working with this reduced test case:Whereas this works:
RamIdeas commentedon Jul 27, 2015
That does, indeed, represent the issue concisely
jmm commentedon Jul 27, 2015
I've been trying to figure this out and it's very difficult because the code is so dense and so sparsely documented, and the call stacks are so gnarly.
So far it seems to me that the key thing is that this
ReferencedIdentifiermethod doesn't get invoked, so an item isn't pushed tostate.references. I think this code inisReferenced()may be important, but I haven't figured the situation out yet. I actually just realized that I think I was misreading the comment on that code until now and thought it didn't match the implementation. Maybe when I look at it again the comment will inform my debugging better.sebmck commentedon Jul 28, 2015
argsinargs = [];isn't aReferencedIdentifier, it's aBindingIdentifier.deopt on binding identifiers with same rest name - fixes #2091
jmm commentedon Jul 28, 2015
@sebmck I'd love to understand this better. What is the summary of what
BindingIdentifierandReferencedIdentifierrepresent? Something like this?BindingIdentifierAn instance of an
IdentifierReferencethat creates a binding or sets the value.ReferencedIdentifierAn instance of an
IdentifierReferencebeing accessed (read).What's the origin of those names?
I also need to look into what "virtual types" actually means in the first place.
sebmck commentedon Jul 28, 2015
@jmm
BindingIdentifierexamples:etc.
ReferencedIdentifieris just like:This is useful as you can't just arbitrarily visit all
Identifiers as then you're visiting:and you can't make many assumptions.
As for virtual types, they're specified in this file. Virtual types are just some way of conditionally considering a node to be of a specific "virtual" type. This is handy as it means you can have more generic standard node types that then become more fine grained through virtual types.
sebmck commentedon Jul 28, 2015
Oh wait, you were asking if those definitions were correct. Yeah, that's basically it. As for the origin of those terms,
BindingIdentifieris used in the ECMAScript specification grammar definitions. Dunno whereReferenceIdentifiercomes from, I don't think I made it up.jmm commentedon Jul 29, 2015
@sebmck Thanks for the info.
Yeah that makes sense. I'd seen that file with the virtual types, just hadn't had the chance to figure out what they represent or how they're implemented yet. Thanks for the description.
Ok, thanks.
Ok, I was wondering because I see
BindingIdentifierin the ES spec, but it appears to represent something different here. I think that in the spec these are notBindingIdentifierbut ratherIdentifierReference:I haven't had the chance to study how these virtual types are used enough to know if that's relevant here.
I don't know if
IdentifierReferenceinspired the nameReferencedIdentifier, but they're obviously very similar and I think used somewhat similarly. Maybe you did make upReferencedIdentifier? I get 1 result for:(JavaScript OR ECMAscript) "ReferencedIdentifier"
Vs thousands for:
(JavaScript OR ECMAscript) "IdentifierReference"
(JavaScript OR ECMAscript) "BindingIdentifier"
Improve optimisation of shadowed rest parameters
Fix optimisation of shadowed rest parameters
Fix optimisation of shadowed rest parameters
Fix optimisation of shadowed rest parameters
Fix optimisation of shadowed rest parameters