Jacob Parker wrote:
Either I'm wrong, or that's missing some parens.
No, test it yourself in Firefox (s/print/console.log/) or SpiderMonkey.
Assume the following (the only interpretation I can see to not throw a
syntax error),
var y = (function (a) a ? f : x++)(1);
In which case, that could only return `f`, which when printed should
print the source of f, no?
No. :-P
But seriously, I'm not sure what your last line means. The mis-parsing
due to precedence inversion means SpiderMonkey (in Firefox) returns f,
not "f", as the value that initializes y, given the minimally
parenthesized testcase:
function f() {return "f"}
var x = 3;
var y = function (a) a ? f : x++(1);
print(y);
FWIW, the consise body of arrow functions won't allow the original
format, and must have surrounding parens.
Yes, arrows are low-precedence (AssignmentExpression alternatives), so
they don't suffer from precedence inversion.
Would just allowing consise bodies on functions work?
No, because function expressions are high-precedence (PrimaryExpression).
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss