Bug 161464 - const keyword should be allowed in strict mode
Summary: const keyword should be allowed in strict mode
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 9
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2016-08-31 16:30 PDT by Jamie Pate
Modified: 2016-08-31 19:26 PDT (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Pate 2016-08-31 16:30:01 PDT
The 'const' keyword has 'basic support' from all major browsers according to http://kangax.github.io/compat-table/es6/

const foo = 123;
return (foo === 123);

Unfortunately, webkit throw an error if the `const` keyword is used in a strict context (via 'use strict'; ).

Steps to Reproduce:
<!DOCTYPE html>
<body style="white-space: pre-wrap">
<script> window.onerror = function(e) { alert(e);console.log.apply(console, arguments) }; </script>
/* jshint globalstrict: true */
/* jshint esnext: true */
'use strict';

function x() {
    const a = 1;
    return a === 1;
var result = 'failure';

try {
    result = x() ? 'success' : 'failure';
} catch (ex) { }

Actual Results: "SyntaxError: Unexpected keyword 'const', Const declarations are not supported in strict mode."

Expected Results: "success" (script executed normally)

Platforms: OSX Safari 9.1.2, iOS webkit 602.1, Phantomjs 2.1.1
Comment 1 Saam Barati 2016-08-31 19:26:13 PDT
Have you tried a webkit nightly? This has been fixed for a while.