You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I still think this issue is invalid. This module is looking for a syntax error in a code string. This code string should not be presumed to be in the top-level context.
If I gave this string...
helloWorld()returnarguments[2]
...to this module, I would not expect to be given an error, even though in this code string helloWorld and arguments are undefined. Those would be runtime errors, not syntax errors. There is nothing syntactically incorrect in that code string.
Yeah, but my argument is that the provided code string should not be assumed to be top-level. The code string could hypothetically be part of a function.
@ArtskydJ I think it depends on use case. For browserify (and my own app devtool) the assumption is the source is not top-level (wrapped in Node's closure).
Perhaps it could be configurable in a third opts parameter.
Activity
ArtskydJ commentedon Jan 27, 2016
I don't see an issue here.
Seems ok on the browser too: https://jsfiddle.net/a32b1nas/1/
michaelficarra commentedon Jan 27, 2016
ArtskydJ commentedon Jan 27, 2016
The JSfiddle was a bad example, sorry.
I still think this issue is invalid. This module is looking for a syntax error in a code string. This code string should not be presumed to be in the top-level context.
If I gave this string...
...to this module, I would not expect to be given an error, even though in this code string
helloWorldandargumentsare undefined. Those would be runtime errors, not syntax errors. There is nothing syntactically incorrect in that code string.Does that make sense?
michaelficarra commentedon Jan 27, 2016
Take a look at the ECMAScript grammar. Trust me, top level returns are a syntax error, not a runtime error.
ArtskydJ commentedon Jan 27, 2016
Yeah, but my argument is that the provided code string should not be assumed to be top-level. The code string could hypothetically be part of a function.
mattdesl commentedon Jan 27, 2016
@ArtskydJ I think it depends on use case. For browserify (and my own app devtool) the assumption is the source is not top-level (wrapped in Node's closure).
Perhaps it could be configurable in a third
optsparameter.EDIT: Updated wording.
ArtskydJ commentedon Jan 27, 2016
@mattdesl That's true. Since a
returnstatement is a SyntaxError in some cases, ideally it should be configurable.Just like the code string shouldn't be assumed to be top-level, it shouldn't be assumed to be non-top-level either.