-
Notifications
You must be signed in to change notification settings - Fork 475
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
Incorrect tests: createdynfn-html-close-comment-(body|params).js #2095
Comments
Pinging @anba and @jugglinmike for help. |
Edit: I'm revisiting the spec from 2017, because it occurred to me that https://tc39.github.io/ecma262/#sec-createdynamicfunction changed since then. I think this one: https://github.com/tc39/test262/blob/master/test/annexB/built-ins/Function/createdynfn-html-close-comment-params.js might've been intended to be written as: Function("", "-->");
Specifically...
This was a really interesting thing to track down. I read the spec and wrote a response; then @leobalter and I read through that response, and the spec, realizing that
...occurs after the parse. So I dug deeper and found this: tc39/ecma262@a3b0507 which I understand to mean that yes, your interpretation of the spec is correct, but doesn't account for the ASI semantics that get applied once that Syntax Error is encountered. |
Step 41 defines the value of Parsing is handled by steps 7-29 (with steps 7, 17 and 18 being the most relevant for this issue). |
It seems to me both tests simply need a leading line-terminator before I no longer remember why I didn't add a line terminator, maybe I forgot it / misread the spec or I was working based on what most engines implement for html-comments, namely that no leading line-terminator is needed: Edit: The Chakra change I referring to → chakra-core/ChakraCore#20 |
Yes, the replacement of |
I was still trying to make sense of all of this w/ @rwaldron and we have some guess over ASI... see #2095 (comment) For the current test purposes the |
It's a guess and I don't have much to offer other than saying that I'm still reading other parts of the specs to understand why this have happened. Usually @anba's tests are safe from bugs and I challenge myself before I assume a bug is a bug. For that, I reconsider everything. In any case, I'm pushing a fix with the |
I would think that changing to
As far as I can tell, every "goal" for parsing should interpret Can anyone else think of a syntactical production that requires a newline before it other than |
* Add new tests to observe required leading line terminator Ref #2095
test/annexB/built-ins/Function/createdynfn-html-close-comment-body.js and test/annexB/built-ins/Function/createdynfn-html-close-comment-params.js i.e.
Function("-->");
andFunction("-->", "");
are supposed to test HTML-like comments and their parsing is expected to pass. Unfortunately, they are incorrect because-->
is not a valid comment. Note that HTMLCloseComment can be either part of SingleLineHTMLCloseComment or MultiLineComment. So it has to be preceeded byLineTerminatorSequence
(to beSingleLineHTMLCloseComment
) or by*/
(to have a chance to beMultiLineComment
). Hence,-->
cannot be parsed as Comment and the mentioned tests should result inSyntaxError
instead.Side note: It seems that major JavaScript engines share my opinion regarding
createdynfn-html-close-comment-params.js
test, i.e., all of them fail it. The only reason that some major JavaScript engines passcreatedynfn-html-close-comment-body.js
test is IMHO the fact that they tend to parseFunction("params","body")
asfunction anonymous(params\n) {\nbody\n}
, i.e., add an artificial line terminator before the body (which turns the body of the form-->
into a valid comment effectively).The text was updated successfully, but these errors were encountered: