Bug 188790

Summary: Wrong output when case clause is a conditional expression
Product: WebKit Reporter: sunlili
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ashvayka, fpizlo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   

Description sunlili 2018-08-21 05:53:34 PDT
Executing following code :
---------------------------------------------
(function()
{
    var f = 0;
    switch (f)
    {
        case ((f = 1)? 0 : 0):
            print("pass");
            break;
        default:
            print(f);
            print("fail");
            break;
    };
})();

print("BT_FLAG");
----------------------------------------------

Output should be :
pass
BT_FLAG

However, output of JavaScriptCore is :
1
fail
BT_FLAG



BT_GROUP
2018/8/21
Comment 1 Alexey Shvayka 2020-06-07 07:42:25 PDT
(In reply to sunlili from comment #0)
> Output should be :
> pass
> BT_FLAG

As of r262695, JSC is correct.
Test: https://trac.webkit.org/browser/webkit/trunk/JSTests/ChakraCore/test/Basics/switch.js?rev=262695#L55.
Comment 2 Radar WebKit Bug Importer 2020-06-07 07:43:17 PDT
<rdar://problem/64089530>