Bug 28236

Summary: Eval doesn't respect JavaScript's const keyword
Product: WebKit Reporter: Joseph Pecoraro <joepeck@webkit.org>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned@lists.webkit.org>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: aroben@webkit.org, barraclough@apple.com, kmccullough@apple.com, oliver@apple.com, timothy@apple.com
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description From 2009-08-12 15:47:31 PST
It seems a const variable declared in the Console is just a "var" and can change value.

    > zzz // ensure it doesn't exist
    ReferenceError: Can't find variable: zzz

    > const zzz = 10;
    undefined

    > zzz = 5; // should do nothing
    5

    > zzz
    5

I would have expected the result to have been 10, since the constant shouldn't change.
------- Comment #1 From 2009-08-12 15:54:30 PST -------
Maybe this is actually a problem with eval():

Expected Behavior without eval:

    javascript:const zza = 10; zza = 5; alert(zza) => 10

Bad Behavior with eval:

    javascript:alert(eval("const zzb = 10; zzb = 5; zzb")) => 5

How should this bug be reclassified?
------- Comment #2 From 2009-08-12 17:18:14 PST -------
Oliver, thoughts?
------- Comment #3 From 2009-08-12 17:20:49 PST -------
Yeah this is a known bug with eval
------- Comment #4 From 2012-03-07 00:32:49 PST -------
We should resolved this by implementing ES Harmony block scoped const.

*** This bug has been marked as a duplicate of bug 31813 ***