Open YaoHouyou opened 5 years ago
@gbrail Can you explain this issue plz? Is this a bug or a implementation property? thx.
I get the desired error if I do one of a few things:
1) Add the "-strict" command-line flag 2) Add 'use strict'; as the first line of the script, before the function is declared. 3) Add 'use strict' right before the declaration of "foo".
It may take some spec-sleuthing to know whether this particular example should fail. If it's supposed to fail unmodified, then somewhere Rhino may not be applying "use strict" at the correct scope, and in that case it's something that Rhino should fix.
I get the desired error if I do one of a few things:
- Add the "-strict" command-line flag
- Add 'use strict'; as the first line of the script, before the function is declared.
- Add 'use strict' right before the declaration of "foo".
It may take some spec-sleuthing to know whether this particular example should fail. If it's supposed to fail unmodified, then somewhere Rhino may not be applying "use strict" at the correct scope, and in that case it's something that Rhino should fix.
Hi, @gbrail, I tested Rhino-1.7.11
and Rhino-1.7.12
according to your three suggestions. The error was not reproduced according to 2th and 3th recommendations. The test cases are as following:
function func() {
'use strict';
function foo(param, param) {
}
foo(2,3);
}
func();
'use` strict';
function func() {
function foo(param, param) {
}
foo(2,3);
}
func();
According to ECMA-262 6th edition, early errors ensure that duplicate parameter names can only occur in non-strict functions [reference]. Rhino does not throw any error in strict mode while others engines throw a syntaxError, such as v8, spiderMonkey, javascriptCore and chakra.
Version:
rhino-1.7.11
,rhino-1.7.10
,rhino-1.7.9
Testcase:
Command: