http://trac.webkit.org/browser/trunk/LayoutTests/js/script-tests/class-syntax-super.js#L40 shouldThrow('x = class extends Base { constructor() { super(); } super() {} }', '"SyntaxError: \'super\' keyword unexpected here"'); If you reformat this: x = class extends Base { constructor() { super(); } super() { } } It should be clear that all this does is define a method named super. There is on restriction on method names like that. Method names can be any keyword.
*** This bug has been marked as a duplicate of bug 144282 ***
Oh wait, this is a separate bug.
I'll take this. I have a simple fix and we ran into this in the inspector recently.
Created attachment 268714 [details] [PATCH] Proposed Fix This catches another bug (bug 152985) and fixes a few issues with keyword method names.
Comment on attachment 268714 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=268714&action=review > Source/JavaScriptCore/parser/Parser.cpp:2158 > + restoreSavePoint(savePoint); > + isStaticMethod = false; Instead of setting a boolean flag back, can we move the condition above into the if condition, initialize isStaticMethod to false, and then set it true when we don't match open paren? That would make this code easier to read without the comment. > Source/JavaScriptCore/parser/Parser.cpp:2184 > + if (!isGenerator && (match(IDENT) || match(STRING) || match(DOUBLE) || match(INTEGER) || match(OPENBRACKET) || m_token.m_type & KeywordTokenFlag)) { Why don't we use isIdentifierOrKeyword instead?
Comment on attachment 268714 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=268714&action=review >> Source/JavaScriptCore/parser/Parser.cpp:2184 >> + if (!isGenerator && (match(IDENT) || match(STRING) || match(DOUBLE) || match(INTEGER) || match(OPENBRACKET) || m_token.m_type & KeywordTokenFlag)) { > > Why don't we use isIdentifierOrKeyword instead? Awesome! I didn't see this existed. Here we can use matchIdentifierOrKeyword()!
Created attachment 268734 [details] [PATCH] Proposed Fix
Comment on attachment 268734 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=268734&action=review > Source/JavaScriptCore/parser/Parser.cpp:2203 > + if (m_token.m_type & KeywordTokenFlag) > + goto namedKeyword; It's annoying that we have to use goto here but I can't think of a better way.
Comment on attachment 268734 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=268734&action=review >> Source/JavaScriptCore/parser/Parser.cpp:2203 >> + goto namedKeyword; > > It's annoying that we have to use goto here but I can't think of a better way. Yeah. `goto` matched the parseProperty handling of keywords in object literals, so I just matched that and used a goto here. We could convert to a bunch of if/else statements, but I'm not sure that would be any clearer.
Comment on attachment 268734 [details] [PATCH] Proposed Fix Clearing flags on attachment: 268734 Committed r194881: <http://trac.webkit.org/changeset/194881>
All reviewed patches have been landed. Closing bug.
*** Bug 153296 has been marked as a duplicate of this bug. ***