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
.sort() keyword parameters are not passed properly #687
I believe I just ran into this issue as well, though in my case it may be bundler related. Oddly enough, it works correctly with Parcel v1, but not with Parcel v2. There is no significant difference in the transpiled code that ends up in the JS bundle though, so the triggering issue in my case lies somewhere outside of Transcrypt. I'd put an issue in with Parcel, but I think the newer version of Parcel actually has the correct behavior (or at least is consistent with other JS environments).
If I understand how it's supposed to work correctly, this code:
changes the value of the key parameter that was passed in, but it is not supposed to alter the value in the arguments object that holds the original values that may get used later on.
In testing the concept in JavaScript just in general with Node and in a web browser, I found that modifying the function parameter does indeed also affect the value in the arguments object. The exception being if the parameters have default values, in which case changing the value of the parameter does NOT change the value in the arguments object. I assume supplying the params with a default value causes them to be instantiated as local vars instead of refs.
That said, I would think that the fact that the variable key is being re-declared in this case, that it should still work regardless. But that may be a JS quirk because using let or const instead of var to redefine it creates a syntax error. This leads me to believe that it is not actually getting re-defined.
Perhaps using explicitly different variables would make it more reliable:
Activity
JennaSys commentedon Aug 30, 2022
I believe I just ran into this issue as well, though in my case it may be bundler related. Oddly enough, it works correctly with Parcel v1, but not with Parcel v2. There is no significant difference in the transpiled code that ends up in the JS bundle though, so the triggering issue in my case lies somewhere outside of Transcrypt. I'd put an issue in with Parcel, but I think the newer version of Parcel actually has the correct behavior (or at least is consistent with other JS environments).
If I understand how it's supposed to work correctly, this code:
changes the value of the
keyparameter that was passed in, but it is not supposed to alter the value in theargumentsobject that holds the original values that may get used later on.In testing the concept in JavaScript just in general with Node and in a web browser, I found that modifying the function parameter does indeed also affect the value in the
argumentsobject. The exception being if the parameters have default values, in which case changing the value of the parameter does NOT change the value in theargumentsobject. I assume supplying the params with a default value causes them to be instantiated as local vars instead of refs.That said, I would think that the fact that the variable
keyis being re-declared in this case, that it should still work regardless. But that may be a JS quirk because usingletorconstinstead ofvarto redefine it creates a syntax error. This leads me to believe that it is not actually getting re-defined.Perhaps using explicitly different variables would make it more reliable:
or, the
keyandreverseparameters could also have default values defined which may solve the issue as well:It took me a while to narrow all this down so I hope it helps someone.
JennaSys commentedon Jul 6, 2024
This has been fixed in the dev_3.9.3 branch to be released in v3.9.3
JennaSys commentedon Jul 17, 2024
Merged to master on PR #876