Open Bug 791294 Opened 12 years ago Updated 2 years ago

Proposal: Add directive flag to ExpressionStatement of Reflect.parse result

Categories

(Core :: JavaScript Engine, enhancement, P5)

All
Unspecified
enhancement

Tracking

()

People

(Reporter: utatane.tea, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 Steps to reproduce: Because no directive flags, we cannot recognize this expression statement is directive or not. Actual results: For example, function t() { ("use strict"); } in this script, "use strict" is not directive. But we have no way to distinguish from function t() { "use strict"; } in Mozilla Parser API AST. Expected results: I suggest that adding directive flag to ExpressionStatement or introducing new statement type, DirectiveStatement.
+1 new statement type, `DirectiveStatement`.
I've opened the same issue to esprima. http://code.google.com/p/esprima/issues/detail?id=330
Either solution would work. If we want to be pedantic about compatibility, directive flag is better since it does not change the syntax node.
Whiteboard: [js:p3]
If I were really looking for true ASTs, I'd expect the () to be visible in the AST, which would let you distinguish the ("use strict") case. But there's also "use\<newline>strict" and "use stri\ct" and "us<escape encoding e> strict" and so on, so a directive annotation of some sort does seem right to me. Best ideally might be having the directive prolog as the left arm of a binary with the right as the actual source statements, but given the existing setup, DirectiveStatement seems right to me.
Assignee: general → nobody

(This remains true )

Blocks: sm-runtime
Severity: normal → S4
Status: UNCONFIRMED → NEW
Type: defect → enhancement
Ever confirmed: true
OS: macOS → Unspecified
Priority: -- → P5
Hardware: x86 → All
Whiteboard: [js:p3]
You need to log in before you can comment on or make changes to this bug.