Normative: CreateDynamicFunction early concatenates bodyText#1479
Normative: CreateDynamicFunction early concatenates bodyText#1479ljharb merged 1 commit intotc39:masterfrom
Conversation
I don't understand this part, hashbang is only allowed when parsing with the goal symbol |
|
@anba right you are. Maybe the only advantage is the convenience for reflecting engines behavior in a very specific usage. |
|
@ljharb the current tests we have on Test262 matches this proposed behavior. If tc39/test262#2101 tc39/test262#2102 get merged those will invert. If we have those PRs on hold until the TC39 meeting the tag for need tests could be discarded. Just to inform, I just want a closing answer for this problem. One way or another, I'm fine with any decision TC39 chooses for this PR. |
|
tc39/test262#2101 is now merged, that means I need a new PR to now reflect this change. |
|
Doing more investigation over this issue I found some similar cases: <script>-->
console.log('foo');</script>
Chrome, Firefox, Safari: will log `'foo'`.
Edge: SyntaxErrorAnyway a file starting with The same issue is also observed with The error is similar to what happens to |
|
There is an interesting observation for the actual output of the Function ctor: That means that ChakraCore is also not compliant to CreateDynamicFunction when the SourceText is not correctly set, it misses the preceding line feed. I wonder if fixing this part would have the same issue observed for HTMLCloseComments. A function like this will be a SyntaxError anywhere: function fn() {-->
}but this function formatting is not: function fn() {
--> valid code
}And this matches the revealed code from As seen in the examples, it makes sense to observe the function body in conjunction with the padding of line feeds added at CreateDynamicFunction. I'm ok to observe the string: |
|
My conclusion is to stick with the proposed change and discuss the problems with eval elsewhere. These are another problem I don't have time and availability to have immediately fixed. Fixing the |
|
Discussed on the editor call; this is ready to go. |
44e7902 to
abb7cbd
Compare
Ref tc39/test262#2102
Ref tc39/test262#2109
This normative change matches the current behavior of V8, SpiderMonkey, and JSC (e.g.
Function("-->"). This is not only for the convenience of reflecting the observed behaviors,but this will allow some guard for potential false positives like.Function("#!hashbang")