New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 709597 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

ReferenceError on setting paramater to default parameter of same name

Reported by rschako...@gmail.com, Apr 7 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Steps to reproduce the problem:
1. Declare function with identical param and default param name
2. Call function

What is the expected behavior?
Works as expected in Firefox.

What went wrong?
Throws that the identifier is undefined, even if previously declared and/or set explicitly.

Applies to functions, arrow functions, and class/object methods.

Did this work before? N/A 

Chrome version: 57.0.2987.133  Channel: stable
OS Version: 16.04
Flash Version: 

var pos = 10

foo = (p = pos) => p      // OK
bar = (pos = pos) => pos  // ReferenceError

console.log(foo())
console.log(bar())
 
I've just realized that the behavior is 'different' in Firefox but not at all 'as expected'.

I had only tried 'var pos' in FF, not 'var pos = 10'. Firefox does not throw, but rather the value silently becomes undefined in the function scope, and remains as-is outside the scope.

Comment 2 by tkent@chromium.org, Apr 10 2017

Components: -Blink Blink>JavaScript
Cc: krajshree@chromium.org
Labels: Needs-Feedback
rschakotay@ - Thanks for filing the issue...!!

Could you please provide a sample html file, expected and actual behavior to test this issue from TE-end.

This will help us in triaging the issue further.

Thanks...!!
Components: -Blink>JavaScript Blink>JavaScript>Language
Owner: adamk@chromium.org
Status: Assigned (was: Unconfirmed)
in Chrome 58 both of them throw the error. I suppose this is expected?

Comment 5 by adamk@chromium.org, Apr 12 2017

Status: WontFix (was: Assigned)
This is working as intended. The "pos = pos" case fails because the "pos" on the right-hand side refers to the "pos" parameter name, but reading from it fails, because it's not yet been initialized.

Sign in to add a comment