Closed Bug 1163851 Opened 10 years ago Closed 10 years ago

Use InHandling to implement restrictions on |in| expressions in the first part of a for(;;) loop

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

References

Details

Attachments

(4 files)

Following up on all the infrastructure landed in bug 1155472. This is approximately a five-liner, modulo ripping out all the manual forparsingForInit maintenance code. This is not a null change from a functionality point of view. At an absolute minimum, it's expected that this should be the case: js> for (x => x in true; false; ) break; typein:3:4 SyntaxError: invalid for/in left-hand side: typein:3:4 for (x => x in true; false; ) break; typein:3:4 ....^ But it's not in the current parsingForInit system.
No functionality change, but without this, later patches in the sequence would be buggy. Also a test for something I misread in the spec grammar. Stupid parser that makes it hard to straightforwardly implement the grammar.
Attachment #8605660 - Flags: review?(efaustbmo)
Alternative to InForInit/NotInForInit I could pass an InHandling argument, but I'd somewhat prefer to leave that for methods that correspond to *actual* grammar terms and such. There's not a single grammar term Parser::variables corresponds to, so I'd prefer something sui generis.
Attachment #8605661 - Flags: review?(efaustbmo)
Attachment #8605660 - Flags: review?(efaustbmo) → review+
Comment on attachment 8605661 [details] [diff] [review] Remove remaining tests of |pc->parsingForInit| Review of attachment 8605661 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/frontend/Parser.cpp @@ +3835,5 @@ > template <typename ParseHandler> > typename ParseHandler::Node > Parser<ParseHandler>::variables(YieldHandling yieldHandling, > + ParseNodeKind kind, > + ForInitLocation location, not that we should have many more callers in the future, but it would be nice to have these default in some nice way. This is more a comment about all of these enums as a whole, rather than this specific instance. Feel free to ignore, but perhaps food for thought. InForInit is very specific.
Attachment #8605661 - Flags: review?(efaustbmo) → review+
Comment on attachment 8605662 [details] [diff] [review] Use the InHandling parameter in the parser to determine when to allow |in| Review of attachment 8605662 [details] [diff] [review]: ----------------------------------------------------------------- Looks great!
Attachment #8605662 - Flags: review?(efaustbmo) → review+
Comment on attachment 8605663 [details] [diff] [review] |pc->parsingForInit| is dead. Long live |InHandling|! Review of attachment 8605663 [details] [diff] [review]: ----------------------------------------------------------------- :) ::: js/src/frontend/Parser.cpp @@ +4850,5 @@ > // 'for (var v = expr1 in expr2) stmt'. > ParseNode* hoistedVar = nullptr; > > + // If there's an |in| keyword here, it's a for-in loop, by dint of careful > + // parsing of |pn1|. I wish this were somehow assertable. It isn't, clearly, but it all seems "very cleverly constructed"
Attachment #8605663 - Flags: review?(efaustbmo) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: