WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
UNCONFIRMED
106176
Non-helpful SyntaxError message for duplicate parameters in strict mode
https://bugs.webkit.org/show_bug.cgi?id=106176
Summary
Non-helpful SyntaxError message for duplicate parameters in strict mode
André Bargull
Reported
2013-01-05 07:22:53 PST
The current SyntaxError message isn't really that helpful. test cases: ---
> function f(a,a){'use strict'}
Exception: SyntaxError: Unexpected token '}'
> function f(a,a){'use strict'; ''}
Exception: SyntaxError: Unexpected string ''
> function f(a,a){'use strict'; return a}
Exception: SyntaxError: Return statements are only valid inside functions ---
Attachments
Add attachment
proposed patch, testcase, etc.
Joseph Pecoraro
Comment 1
2016-10-13 20:29:15 PDT
Things are slightly better now. It would still be nice if it said duplicate parameters though. Current state of things (
r207235
): js> function f(a,a){'use strict'} Invalid parameters or function name in strict mode.:1 js> function f(a,a){'use strict'; ''} Invalid parameters or function name in strict mode.:1 js> function f(a,a){'use strict'; return a} Invalid parameters or function name in strict mode.:1
Joseph Pecoraro
Comment 2
2016-10-13 20:33:03 PDT
Compare to our error message for classes and arrow functions which force the stricter parsing, these are more helpful because they even note the duplicate parameter: js> (class { f(a,a){} }) Cannot declare a parameter named 'a' in strict mode as it has already been declared.:1 js> (class { f(a,a){''} }) Cannot declare a parameter named 'a' in strict mode as it has already been declared.:1 js> (class { f(a,a){return a} }) Cannot declare a parameter named 'a' in strict mode as it has already been declared.:1 js> (a,a) => {} Duplicate parameter 'a' not allowed in an arrow function.:1 js> (a,a) => {''} Duplicate parameter 'a' not allowed in an arrow function.:1 js> (a,a) => {return a} Duplicate parameter 'a' not allowed in an arrow function.:1
Saam Barati
Comment 3
2016-10-15 13:29:54 PDT
Weird I thought we had code that said it's invalid because of duplicate parameters when we parse "use strict". I'll look into it
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug