Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upBehavior of for-in on null or undefined #377
Comments
bterlson
added
the
question
label
Feb 17, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Feb 17, 2016
Member
It does eventually return an undefined value with a normal completion. The break completion value is handled uniformly in 13.1.7. I'm not sure if the break semantics are required for some reason but it does just work with the existing machinery so that's a plus. You could imagine (I think) checking the result of evaluating the head in each block of 13.7.5.11, though I'm not inclined to change this without good reason.
|
It does eventually return an undefined value with a normal completion. The break completion value is handled uniformly in 13.1.7. I'm not sure if the break semantics are required for some reason but it does just work with the existing machinery so that's a plus. You could imagine (I think) checking the result of evaluating the head in each block of 13.7.5.11, though I'm not inclined to change this without good reason. |
bterlson
closed this
Feb 17, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thank you, I missed that. |
GeorgNeis commentedFeb 10, 2016
What should happen when trying to enumerate (for-in) null or undefined? If I understand the spec correctly, currently such a for-in statement is equivalent to a break, which I find very strange:
http://tc39.github.io/ecma262/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind
(I would have expected that this returns a normal completion record with the undefined value.)