Closed
Bug 1275240
Opened 7 years ago
Closed 7 years ago
Redeclaration of formal parameter with lexical binding should be SyntaxError
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
Details
(Keywords: dev-doc-complete)
Attachments
(1 file)
3.22 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
|function f(a) { let a }| should throw SyntaxError, but we throw TypeError js> function f(a) { let a } typein:1:20 TypeError: redeclaration of formal parameter a: typein:1:20 function f(a) { let a } typein:1:20 ....................^ https://tc39.github.io/ecma262/#sec-function-definitions-static-semantics-early-errors > * It is a Syntax Error if any element of the BoundNames of FormalParameters also occurs in the LexicallyDeclaredNames of FunctionBody.
Assignee | ||
Comment 1•7 years ago
|
||
Now testing the patch https://treeherder.mozilla.org/#/jobs?repo=try&revision=cf6a34839cbc so far, single test fails https://dxr.mozilla.org/mozilla-central/source/js/src/tests/js1_8_1/regress/regress-452498-092.js
Comment 2•7 years ago
|
||
fwiw, with strict mode warnings, this code also throws a TypeError warning and not a SyntaxError warning: function f(arg) { var arg } TypeError: variable arg redeclares argument That's JSMSG_VAR_HIDES_ARG and it appears quite often according to current Telemetry data.
Keywords: dev-doc-needed
Assignee | ||
Comment 3•7 years ago
|
||
(In reply to Florian Scholz [:fscholz] (MDN) from comment #2) > fwiw, with strict mode warnings, this code also throws a TypeError warning > and not a SyntaxError warning: > function f(arg) { var arg } > > TypeError: variable arg redeclares argument > > That's JSMSG_VAR_HIDES_ARG and it appears quite often according to current > Telemetry data. redeclaration with "var" is different thing than let/const. not sure if that warning is specced thing. will check it :)
Summary: Redeclaration of formal parameter should be SyntaxError → Redeclaration of formal parameter with lexical binding should be SyntaxError
Assignee | ||
Comment 4•7 years ago
|
||
the type of warning is not specced, so at least JSMSG_VAR_HIDES_ARG is not something we should change its type here.
Assignee | ||
Comment 6•7 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/97d4fa9f099b14a98d4242f1c73507beb1f70081 Bug 1275240 - Fix the type of parameter redeclaration from TypeError to SyntaxError. r=shu
Comment 7•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/97d4fa9f099b
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Comment 8•7 years ago
|
||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Redeclared_parameter
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•