Duplicate parameter names in non-strict function cause assertion failure in InitializeBinding
# Allen Wirfs-Brock (13 years ago)
Yes, that is an issue. There are some others relating to formal parameter initialization. Basically, I need to make another pass over that algorithm particular in regard to formals.
Thanks for point this out. In the future it would be best to report such issues using bugs.ecmascript.org That makes it easier to track them.
Yes, that is an issue. There are some others relating to formal parameter initialization. Basically, I need to make another pass over that algorithm particular in regard to formals. Thanks for point this out. In the future it would be best to report such issues using bugs.ecmascript.org That makes it easier to track them. Allen On May 27, 2012, at 9:00 PM, Yusuke Suzuki wrote: > Hello, > > In the latest ES.next draft(May 4), section 10.5.3 Function Declaration Instantiation step 5 is following > > 5. For each String argName in parameterNames, in list order do > a. Let alreadyDeclared be the result of calling env’s HasBinding concrete method passing argName as the argument. > b. NOTE Duplicate parameter names can only occur in non-strict code. > c. If alreadyDeclared is false, then > i. Call env’s CreateMutableBinding concrete method passing argName as the argument. > d. If strict is false, then > i. Call env’s InitializeBinding concrete method passing argName, and undefined as the arguments. > > In the step d-i, if strict is false, engine always call env.InitializeBinding(argName, undefined). > But if code is non-strict mode, duplicate parameter names may be provided. > > And section 10.2.1.1.8, InitializeBinding, step 2 is following > > 2. Assert: envRec must have an uninitialised binding for N. > > So for example, > > // this is non-strict function > function test(a, a) { > } > test(1, 1); > > engine execute above script and raise assertion failure because of calling InitializeBinding to the same name twice. > > So I suggest changing like this > > c. If alreadyDeclared is false, then > i. Call env’s CreateMutableBinding concrete method passing argName as the argument. > ii. If strict is false, then > 1. Call env’s InitializeBinding concrete method passing argName, and undefined as the arguments. > > If I missed something, please point out. > > Regards, > Yusuke Suzuki > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120527/f0b1d799/attachment-0001.html>
# Yusuke Suzuki (13 years ago)
Thanks for your reply. So I've filed the issue in https://bugs.ecmascript.org/show_bug.cgi?id=368 Regards, Yusuke Suzuki On Mon, May 28, 2012 at 1:54 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote: > Yes, that is an issue. There are some others relating to formal parameter > initialization. Basically, I need to make another pass over that algorithm > particular in regard to formals. > > Thanks for point this out. In the future it would be best to report such > issues using bugs.ecmascript.org That makes it easier to track them. > > Allen > > > On May 27, 2012, at 9:00 PM, Yusuke Suzuki wrote: > > Hello, > > In the latest ES.next draft(May 4), section 10.5.3 Function Declaration > Instantiation step 5 is following > > 5. For each String argName in parameterNames, in list order do >> a. Let alreadyDeclared be the result of calling env’s HasBinding >> concrete method passing argName as the argument. >> b. NOTE Duplicate parameter names can only occur in non-strict code. >> c. If alreadyDeclared is false, then >> i. Call env’s CreateMutableBinding concrete method passing argName >> as the argument. >> d. If strict is false, then >> i. Call env’s InitializeBinding concrete method passing argName, >> and undefined as the arguments. > > > In the step d-i, if strict is false, engine always call > env.InitializeBinding(argName, undefined). > But if code is non-strict mode, duplicate parameter names may be provided. > > And section 10.2.1.1.8, InitializeBinding, step 2 is following > > 2. Assert: envRec must have an uninitialised binding for N. > > > So for example, > > // this is non-strict function > function test(a, a) { > } > test(1, 1); > > > engine execute above script and raise assertion failure because of calling > InitializeBinding to the same name twice. > > So I suggest changing like this > > c. If alreadyDeclared is false, then >> i. Call env’s CreateMutableBinding concrete method passing argName >> as the argument. >> ii. If strict is false, then >> 1. Call env’s InitializeBinding concrete method passing argName, >> and undefined as the arguments. > > > If I missed something, please point out. > > Regards, > Yusuke Suzuki > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120528/188c8bb7/attachment.html>
Hello,
In the latest ES.next draft(May 4), section 10.5.3 Function Declaration Instantiation step 5 is following
In the step d-i, if strict is false, engine always call env.InitializeBinding(argName, undefined). But if code is non-strict mode, duplicate parameter names may be provided.
And section 10.2.1.1.8, InitializeBinding, step 2 is following
So for example,
// this is non-strict function function test(a, a) { } test(1, 1);
engine execute above script and raise assertion failure because of calling InitializeBinding to the same name twice.
So I suggest changing like this
If I missed something, please point out.
, Yusuke Suzuki