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

[BUGFIX release] Fix overwriting rest positional parameters when passed as named parameters. #14509

Merged
merged 1 commit into from
Oct 27, 2016

Conversation

Serabe
Copy link
Member

@Serabe Serabe commented Oct 23, 2016

If rest positional parameters are passed as named arguments, it might
not be passed to the component when called with a contextual component.

Example:

{{component (component "link-to") params=someParams}}

Fix #14508

@Serabe
Copy link
Member Author

Serabe commented Oct 23, 2016

There is a test failing because jshint does not like the line:

let Symbol = Symbol || null;

And cannot find a way around it :$

I guess this needs to be backported to LTS since it is a regression introduced partially in 2.7 (no transition) and 2.8 (breaks). Checking this next.

Thank you for taking the time to look at this PR!

@Serabe
Copy link
Member Author

Serabe commented Oct 23, 2016

I checked and this commit can be cherry-picked on top of lts-2-8 without problem. I have also a branch with that done in my fork.

@Serabe
Copy link
Member Author

Serabe commented Oct 23, 2016

Uhm, the test is not failing in CI but in local does :$

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here look good, can you PR the new tests against master so we keep them?

Also, does this need to be pulled back into lts-2-8 (now that 2.9 is release)? If it does, can you update commit message to be [BUGFIX lts-2-8]?

@@ -10,6 +10,7 @@ QUnit.module('Ember Metal Utils');
QUnit.test('inspect outputs the toString() representation of Symbols', function() {
// Symbol is not defined on pre-ES2015 runtimes, so this let's us safely test
// for it's existence (where a simple `if (Symbol)` would ReferenceError)
/* jshint latedef: false */
let Symbol = Symbol || null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty wild. Can we just change it (future PR is fine)?

I think this is a better guard (below):

if (typeof Symbol !== 'undefined') {

}

Then we don't have to do any global clobbering variables...

Copy link
Member

@stefanpenner stefanpenner Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surprising, why wouldn't let S = S || null throw a ReferenceError?

Copy link
Member

@stefanpenner stefanpenner Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the following very much fails:

(function() { let Symbol = Symbol || null;}());

with

VM257:1 Uncaught ReferenceError: Symbol is not defined

let Symbol ensures that before the let that Symbol is in a TDZ. basically, it is non-addressable until after the let. As it turns out, the right hand side of let Symbol = <right hand side> is technically before the let, and since let has reserved Symbol for that scope, even if the a global Symbol exists, this should error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened a comment on a closed babel issue: babel/babel#527 (comment)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment (can add a tdz option to the plugin)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hzoo thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitted #14531 to fix this specific test in release/lts-2-8 branches, and they were already fixed in #14267 (see here).

@homu
Copy link
Contributor

homu commented Oct 27, 2016

☔ The latest upstream changes (presumably #14531) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -10,6 +10,7 @@ QUnit.module('Ember Metal Utils');
QUnit.test('inspect outputs the toString() representation of Symbols', function() {
// Symbol is not defined on pre-ES2015 runtimes, so this let's us safely test
// for it's existence (where a simple `if (Symbol)` would ReferenceError)
/* jshint latedef: false */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this and rebase now that #14531 is landed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it!

…ed as named

parameters.

If rest positional parameters are passed as named arguments, it might
not be passed to the component when called with a contextual component.

Example:

```hbs
{{component (component "link-to") params=someParams}}
```

Fix emberjs#14508
@rwjblue rwjblue merged commit a27601f into emberjs:release Oct 27, 2016
@rwjblue
Copy link
Member

rwjblue commented Oct 27, 2016

Pulled into lts-2-8 branch

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

Successfully merging this pull request may close these issues.

5 participants