Bug 159968 - [JSC] Unary + changes evaluation order
Summary: [JSC] Unary + changes evaluation order
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
Depends on:
Reported: 2016-07-20 04:06 PDT by Yusuke Suzuki
Modified: 2016-07-20 04:07 PDT (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2016-07-20 04:06:58 PDT
Currently, we just strip the unary + in makeXXXNode. But unary + can change the evaluation order since it performs ToNumber.

Modified tests derived from the Rick Waldron's one. 

            let capture = [];
            let leftValue = { valueOf() { capture.push("leftValue"); return 3; }};
            let rightValue = { valueOf() { capture.push("rightValue"); return 2; }};

            (capture.push("left"), leftValue) ${token} +(capture.push("right"), rightValue);
            //                                         ^
            //                                 Changes the order

            // Expected per operator evaluation order: "left", "right", "rightValue", "leftValue"
            shouldBe(capture[0], "left");
            shouldBe(capture[1], "right");
            shouldBe(capture[2], "rightValue");
            shouldBe(capture[3], "leftValue");