Bug 188790 - Wrong output when case clause is a conditional expression
Summary: Wrong output when case clause is a conditional expression
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-21 05:53 PDT by sunlili
Modified: 2020-06-07 07:43 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>