Method definitions require curly brackets

RESOLVED FIXED in Firefox 41

Status

()

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: evilpie, Assigned: evilpie)

Tracking

(Blocks: 1 bug, {addon-compat, dev-doc-complete})

unspecified
mozilla41
addon-compat, dev-doc-complete
Points:
---

Firefox Tracking Flags

(firefox41 fixed)

Details

Attachments

(2 attachments)

(Assignee)

Description

4 years ago
I blame FunctionType vs FunctionSyntaxKind, we really need to unify those!

This is not valid in ES6: var o = {x() 12};
(Assignee)

Updated

4 years ago
Assignee: nobody → evilpies
(Assignee)

Comment 1

4 years ago
Attachment #8607576 - Flags: review?(efaustbmo)
(Assignee)

Updated

4 years ago
Attachment #8607578 - Flags: review?(jaws)
Comment on attachment 8607576 [details] [diff] [review]
Disallow method syntax without curly brackets

Review of attachment 8607576 [details] [diff] [review]:
-----------------------------------------------------------------

Wfm. We should address getters and setters in some way.

::: js/src/frontend/Parser.cpp
@@ +2563,5 @@
>      TokenKind tt;
>      if (!tokenStream.getToken(&tt, TokenStream::Operand))
>          return false;
>      if (tt != TOK_LC) {
> +        if (funbox->isStarGenerator() || kind == Method || kind == ClassConstructor) {

This should also include kind == Getter && kind == Setter, but my understanding is that this will be a lot more painful to update our code to be compliant with that. We still need to do that, though. Can we leave-open this bug, or file a followup to handle that?

::: js/src/tests/js1_8_5/reflect-parse/methodDefn.js
@@ +12,5 @@
>  
> +// Method definitions without braces
> +assertError("({ a() void 0 })", SyntaxError);
> +assertError("({ a() 1 })", SyntaxError);
> +assertError("({ a() false })", SyntaxError);

Can we test this in classes as well?
Attachment #8607576 - Flags: review?(efaustbmo) → review+
https://hg.mozilla.org/mozilla-central/rev/6cf58656d6fb
https://hg.mozilla.org/mozilla-central/rev/0135ea20609a
Status: NEW → RESOLVED
Last Resolved: 4 years ago
status-firefox41: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
(Assignee)

Updated

4 years ago
Keywords: addon-compat, dev-doc-needed
> Leaving ddn open for Kohei/site-compat for now.
https://developer.mozilla.org/en-US/Firefox/Releases/41/Site_Compatibility#JavaScript
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.