Closed
Bug 932513
Opened 11 years ago
Closed 9 years ago
Enable let without version=1.7+ in strict mode
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 932517
People
(Reporter: cpeterson, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, feature, Whiteboard: [DocArea=JS][Docs see comment 17 too])
Attachments
(1 file)
1.45 KB,
patch
|
Details | Diff | Splinter Review |
This bug is forked from bug 855665. In bug 855665 comment 19, Rick Waldron says:
`let` in strict code is a non-issue, because `let` is reserved in strict code. The committee agreed to move forward with `let` in non-strict code, b/w a lookahead:
https://github.com/rwaldron/tc39-notes/blob/master/es6/2012-11/nov-29.md#conclusionresolution-6
Comment 2•11 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #1)
> But we should implement ES6 semantics first.
This is really important, since it's not a matter of just "switching on" support. Specifically, the semantics are defined in "13.2.1 Let and Const Declarations" need to be implemented and let is incorrectly scoped in for loops:
<script type="application/javascript;version=1.8">
var a = [];
for (let i = 0; i < 5; i++) {
a.push(function() { return i; });
}
console.log(a[0]() === 0);
</script>
outputs `false`, but should be `true`
There may be other discrepancies, this is just what I know off hand
Updated•10 years ago
|
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Reporter | ||
Updated•10 years ago
|
Summary: Enable let without version=1.8 in strict mode → Enable let without version=1.7+ in strict mode
Reporter | ||
Comment 3•10 years ago
|
||
let is currently available in javascript;version=1.7 and 1.8.
Comment 4•9 years ago
|
||
It's sad that this is still not working (and making cross browser us of `let` impossible). How can we enable this by default? Chrome reject code with "javascript;version=1.7".
<script src="/myScript.js" type="application/javascript;version=1.8" async></script>
<script src="/myScript.js" language="Javascript1.7" async></script>
Chrome will ignore the first line. Firefox will ignore the second. Together they'll allow development using let.
Comment 6•9 years ago
|
||
Wait, why does it work for me in Firefox 38.0.5 in the console without any problems?
(function () {
'use strict';
let x = 3;
{
let x = 4;
console.log(x);
}
console.log(x);
})();
It prints:
4
3
as expected.
Reporter | ||
Comment 7•9 years ago
|
||
(In reply to Michał Gołębiowski [:m_gol] from comment #6)
> Wait, why does it work for me in Firefox 38.0.5 in the console without any
> problems?
Firefox's web console defaults to JavaScript version 1.8.5, whereas web content defaults to JavaScript 1.5.
Comment 8•9 years ago
|
||
This distinction seems troublesome as devs are often trying something in the dev console and assuming that if it works there it works on the Web.
This is the first time I've heard those two are different. What's the reason for that? Does any other browser have such a distinction?
This doesn't seem to be in line with the whole 1JS philosophy that ECMAScript now follows.
AFAIK no other browsers have the concept of versioned scripts, and just impose the latest version on all scripts. Is it not possible for Firefox to do the same? It sounds like it should still be compatible since all other browsers do that already.
Reporter | ||
Comment 10•9 years ago
|
||
That's a good point. It does seem like the Web Console should use the same 1JS available to web content, but perhaps allow developers to test nonstandard JS 1.8.5 features (available to Firefox internals and add-ons) in Firefox's Browser Console.
(In reply to Chris Peterson [:cpeterson] from comment #10)
> That's a good point. It does seem like the Web Console should use the same
> 1JS available to web content, but perhaps allow developers to test
> nonstandard JS 1.8.5 features (available to Firefox internals and add-ons)
> in Firefox's Browser Console.
This approach makes sense to me. I didn't realize this was happening until today!
I filed bug 1173883 to change the console.
See Also: → 1173883
Comment 12•9 years ago
|
||
(In reply to Chris Peterson [:cpeterson] from comment #10)
> That's a good point. It does seem like the Web Console should use the same
> 1JS available to web content, but perhaps allow developers to test
> nonstandard JS 1.8.5 features (available to Firefox internals and add-ons)
> in Firefox's Browser Console.
Wait, we are relying on nonstandard features in production code (i.e., `let` is used everywhere in Gecko's JSMs, etc.)? What is going to happen when we "fix" let? won't potentially our internal code break?
Reporter | ||
Comment 13•9 years ago
|
||
Yes. Bug 950547 has more information about making SpiderMonkey's `let` and `const` compatible with ES6.
Comment 14•9 years ago
|
||
I see a lot of talk about why, but no patches on how. :) I'm curious what a patch for this would look like.
Updated•9 years ago
|
Comment 15•9 years ago
|
||
It would be super useful for Gaia to get this. We're moving a lot of code to ES6 and naturally we want to use `let` to avoid creating another pile of technical debt for years to come.
All our code is in `strict mode`, so we would benefit from it instantly and would be able to stop requiring transpilers which increase entry barrier and tie us to build time operations.
Comment 16•9 years ago
|
||
This breaks the web. Let and Const are two of the most supported features of es6, even IE11 supports it, but with Firefox only allowing let behind this script versioning it makes it basically impossible to sanely use well supported es6 features in production cross-browser code. Perfect example, I work on a pretty big AngularJS project at work, and we would love to be able to start implementing ES2015 features, but this bug is currently holding us back.
Updated•9 years ago
|
Blocks: webextensions-chrome-gaps
Comment 18•9 years ago
|
||
dev-doc |
Note that beside the usual JS documentation, we will need to update this one (Kris just edited it) when this land too: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities
(Posting it here so we don't forget)
Whiteboard: [DocArea=JS] → [DocArea=JS][Docs see comment 17 too]
Comment 19•9 years ago
|
||
Here is very simple patch.
How much problem does this patch file produce?
Comment 20•9 years ago
|
||
Shu enabled let in sloppy and strict mode at the same time.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
Comment 21•9 years ago
|
||
ooh I have to revise my site compat doc again...
Comment 22•9 years ago
|
||
The comment on https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities has been removed.
Also updated:
https://developer.mozilla.org/en-US/Firefox/Releases/44#JavaScript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•