Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js 4.x "let basic support" is "Yes" wrongly. It must be "Error" #52

Open
mysticatea opened this issue May 7, 2018 · 8 comments
Open

Comments

@mysticatea
Copy link

image
http://node.green/#ES2015-bindings-let

let basic support on Node.js 4.x seems yes, however, I believe it throws syntax error.

$ node -v
v4.9.1
$ cat test.js
function f() {
    let foo = 123;
    return (foo === 123);
}
$ node test.js
~/test.js:2
    let foo = 123;
    ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:140:18)
    at node.js:1043:3
@devsnek
Copy link

devsnek commented May 10, 2018

like the error says, you have to use strict mode[1] for block scoped declarations. they work fine in node 4.9

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

@mysticatea
Copy link
Author

@devsnek I know. You are saying about "basic support (strict mode)" entry. It's "yes" in the table correctly.

@mysticatea mysticatea changed the title Node.js 4.x has let basic support? Node.js 4.x "let basic support" is "Yes" wrongly. It must be "Error" May 19, 2018
@mysticatea
Copy link
Author

cc/ @williamkapke

@williamkapke
Copy link
Owner

williamkapke commented May 22, 2018

Sry, I've been away for awhile.

@mysticatea I see what you're talking about. There are 2 reason why it's like this:

Mimicking how the Kangax test works:
https://github.com/kangax/compat-table/blob/3a2e829cbc5026195bb8e2ac2e24c9c0c9f3efd8/build.js#L778-L801

https://github.com/williamkapke/node-compat-table/blob/gh-pages/test.js#L82-L83

It first tries without strict- and then, if failure, tries WITH strict.

Being Green
The goal of node.green has always been to try to lean towards showing what is possible with a specific version of node (causing more green than red). Initially, I had even the "Flag" ones as "Yes" and in green! After much debate, I changed that (to how it is today) and decided to draw a line at what could be available by a developer writing code in javascript (as opposed to cmd line flags which isn't a javascript thing).

Adding "use strict"; is something a developer can do in JS to make it work.


An indicator that strict was needed- would certainly be MORE helpful, but alas- I didn't take the time to capture and display that. (it applied to so few things, I couldn't justify getting to it in my backlog)

As always- a PR is welcome!

@mysticatea
Copy link
Author

@williamkapke In that case, I have a question. Why do you separate basic support and basic support (strict mode)? The separated entries are confusing.

@williamkapke
Copy link
Owner

Ahh... now I fully understand what you're asking about. Sorry I didn't catch that.

Since they're broken out- yes, it seems we could remove the strict fallback test (for node.green's purposes). It's easy enough to remove-- but I wonder how much it will change other test results 🤔

Will need to try it and see!

@williamkapke williamkapke reopened this May 23, 2018
@williamkapke
Copy link
Owner

Ok. strict mode fallback has been removed.

There were many changes. See:
455b9a2

Anything seem like a bad side effect?

@mysticatea
Copy link
Author

mysticatea commented May 26, 2018

Class syntax seems to become Error similar to let/const, but classes don't have (strict mode) entries.

And some entries are using class syntax in their test functions. E.g., Generators: shorthand generator methods, classes. Those will become Yes under strict mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants