Closed Bug 638667 Opened 10 years ago Closed 6 years ago

Disallow keywords as function names, in function statements/expressions


(Core :: JavaScript Engine, defect)

Not set





(Reporter: Waldo, Assigned: Waldo)



(1 file)

Attached patch diff -wSplinter Review
This already happens for strict mode code, needs to happen for regular code too.  It looks like we unreserved with the expectation that ES4 would do this, but of course ES4 never happened.  ES5 unreserved in a few places (property names in literals, property-name in member expressions and call expressions), but it did not unreserve in the function-name context.  At this juncture harmonizing again seems like a good idea.
Attachment #516781 - Flags: review?(brendan)
Harmony != ES5.

Changing the grammar to use IdentifierName instead of Identifier after 'function' keywords (and sharps) is under consideration for Harmony. There's no need to spend scarce hacker time on this if it's going away again, and in the mean time some Mozilla-specific code has come to depend on it.

Yeah, too soon. Don't remove stuff before you know what Harmony will do. Harmony *starts* with ES5 strict, but is not limited to ES5 strict.

I didn't mean to imply that, guess "harmonizing" was an overloaded word in that context -- rather to do like other implementations do.

I have to say, I'm rather aghast that this extension makes things like this into valid syntax:

  function function() { }
> I have to say, I'm rather aghast that this extension makes things like this
> into valid syntax:
>   function function() { }


With all the things that can go wrong in a language, this just seems to me like a benign curiosity. People like to laugh at PL/1's |let let = let in let(let)| or whatever the old example is, but Lisp and Scheme have always let you rebind keywords (or more accurately, they simply have no reserved keywords) and I've never seen anything go wrong as a result. Unless someone can demonstrate real problems caused by this, I won't be clutching my pearls and reaching for the smelling salts.

Comment on attachment 516781 [details] [diff] [review]
diff -w

Clearing some old reviews. This one isn't truly ancient but I don't see an r+ coming.
Attachment #516781 - Flags: review?(brendan)
Closed: 6 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 907958
You need to log in before you can comment on or make changes to this bug.