Closed Bug 1243858 Opened 8 years ago Closed 8 years ago

Exponentiation Operator precendence update (ES2016/ES7, Stage 4)

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: rwaldron, Assigned: anba)

References

()

Details

(Keywords: dev-doc-complete, Whiteboard: [DocArea=JS])

Attachments

(1 file, 1 obsolete file)

Exponentiation Operator reached stage 4 status today and the normative spec will be merged with Ecma 262 (https://github.com/tc39/ecma262/pull/318)
Blocks: es7
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
(In reply to Rick Waldron [:rwaldron] from comment #1)
> fscholz, I've updated the MDN docs for exp op: 
> 
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/
> Arithmetic_Operators#Exponentiation_(**)

Waldron, is (-2) ** 2 also a syntax error?
(In reply to ziyunfei from comment #2)
> (In reply to Rick Waldron [:rwaldron] from comment #1)
> > fscholz, I've updated the MDN docs for exp op: 
> > 
> > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/
> > Arithmetic_Operators#Exponentiation_(**)
> 
> Waldron, is (-2) ** 2 also a syntax error?

No, it's not. 


Also, I think the ids on that page need to have "(" and ")" removed, so they don't break the fragment urls.
(In reply to Rick Waldron [:rwaldron] from comment #3)
> Also, I think the ids on that page need to have "(" and ")" removed, so they
> don't break the fragment urls.
All operators on that page are also linked without their syntax, like this:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation 
Unfortunately, I can't control what is in the TOC as it is generated automatically.
Is it OK to use Exponentiation Operator on Firefox Stable version now?

I try on Firefox Stable and Developer Edition, both failed.
> 2**3
> SyntaxError: expected expression, got '*'
(In reply to Liu Xing from comment #5)
> Is it OK to use Exponentiation Operator on Firefox Stable version now?

It is currently only available on Nightly. See bug 1198453. I couldn't find a bug for letting it ride the trains (move to the other releases), though. Not sure whether this will be covered in this bug, too, or a new bug will be created.

Sebastian
Depends on: 1135708
(In reply to Sebastian Zartner [:sebo] from comment #6)
> (In reply to Liu Xing from comment #5)
> > Is it OK to use Exponentiation Operator on Firefox Stable version now?
> 
> It is currently only available on Nightly. See bug 1198453. I couldn't find
> a bug for letting it ride the trains (move to the other releases), though.
> Not sure whether this will be covered in this bug, too, or a new bug will be
> created.
> 
> Sebastian

Thank you very much.
Blocks: 1291212
Attached patch exp_op_unary.patch (obsolete) — Splinter Review
I think this approach should suffice to meet the left-hand side restriction, but I'm not 100% sure, therefore I'm only asking for feedback at this point.
Attachment #8792575 - Flags: feedback?(arai.unmht)
Assignee: nobody → andrebargull
I'm missing the context.

where is the latest spec or proposal?
this, or somewhere else?
  http://rwaldron.github.io/exponentiation-operator/
Flags: needinfo?(andrebargull)
https://tc39.github.io/ecma262/#sec-exp-operator probably?
Flags: needinfo?(andrebargull)
Comment on attachment 8792575 [details] [diff] [review]
exp_op_unary.patch

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

looks good.

::: js/src/js.msg
@@ +201,5 @@
>  MSG_DEF(JSMSG_BAD_INCOP_OPERAND,       0, JSEXN_REFERENCEERR, "invalid increment/decrement operand")
>  MSG_DEF(JSMSG_BAD_METHOD_DEF,          0, JSEXN_SYNTAXERR, "bad method definition")
>  MSG_DEF(JSMSG_BAD_OCTAL,               1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant")
>  MSG_DEF(JSMSG_BAD_OPERAND,             1, JSEXN_SYNTAXERR, "invalid {0} operand")
> +MSG_DEF(JSMSG_BAD_POW_LEFTSIDE,        0, JSEXN_SYNTAXERR, "invalid operand for '**' expression")

it would be nice to suggest adding parenthesis to either lhs or whole exponentiation expression, if it can be described in short.
(we could explain the detail in MDN document tho)
Attachment #8792575 - Flags: feedback?(arai.unmht) → feedback+
Attached patch bug1243858.patchSplinter Review
The error message has been amended to explain why the operand is invalid ("unparenthesized unary expression").

Drive-by change: Updated JSMSG_ARRAY_INIT_TOO_BIG to use AE/OED instead of BE spelling ("initialiser" -> "initializer").
Attachment #8792575 - Attachment is obsolete: true
Attachment #8798465 - Flags: review?(arai.unmht)
Attachment #8798465 - Flags: review?(arai.unmht) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/80683e82570c
Disallow unary expression on left-hand side of exponentiation operator. r=arai
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/80683e82570c
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in before you can comment on or make changes to this bug.