Round-trip change with nested ternary and extra parens

RESOLVED DUPLICATE of bug 352261

Status

()

Core
JavaScript Engine
--
minor
RESOLVED DUPLICATE of bug 352261
12 years ago
12 years ago

People

(Reporter: Jesse Ruderman, Unassigned)

Tracking

(Blocks: 1 bug, {testcase})

Trunk
PowerPC
Mac OS X
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
js> p = function() { return (x ? 1 : 2) ? 3 : 4 }
function () {
    return x ? 1 : 2 ? 3 : 4;
}

js> eval("" + p)
function () {
    return x ? 1 : 3;
}

I don't know if this is just a round-trip change (harmless except for fuzzing) or an indicator that there's a real bug.
This is a parenthesization bug.  ?: is right associative, you are forcing left association, your parens should be preserved.  They are if you update your build:

js> p = function() { return (x ? 1 : 2) ? 3 : 4 }
function () {
    return (x ? 1 : 2) ? 3 : 4;
}

This is a dup of bug 352261.

/be

*** This bug has been marked as a duplicate of 352261 ***
Status: NEW → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.