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 upPost ES2015 breaking change to If statement completion value? #1085
Comments
allenwb
added
the
spec bug
label
Jan 28, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
This was changed in #101. |
allenwb
referenced this issue
Feb 1, 2018
Open
This requires JS programmers to learn a bunch of trivia #21
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
allenwb commentedJan 28, 2018
This was first discussed in a do expression proposal issue tc39/proposal-do-expressions#21 (comment)
The behavior of
ifseems to have changed between ES2015 and the current ES2018 draft:In 2015:
{ 1; if (true) break; }produces the completion value for the block: [[Type]: break, [[Value]]: 1
and
{ 1; if (true) ; }produces the completion value for the block: [[Type]: Normal, [[Value]]: undefined.
In the ES2018 draft, they respectively produce:
[[Type]: break, [[Value]]: undefined
[[Type]: Normal, [[Value]]: undefined
The algorithm conventions for manipulating completion results changed between those versions of the spec. It isn't obvious to me that the semantic change was intentional. It could be a bug introduced when rewriting using the new conventions. It probably should be researched to see if the 2015 behavior had been identified as a bug and the change was an intentional fix.
The bigger question is what (if anything) was the intent of "completion reform" for cases like this. It's pretty clear that a goal of completion reform was that during linear progress, each statement either always or never produces a new completion value. But abrupt completions are really a separate dimensions of completion value propagation, so it isn't obvious that the always/never rule should apply to it.
In seems strange to me that:
{ 1; break; }would have a completion value of
[[Type]: break, [[Value]]: 1But,
{ 1; if (true) break; }has a completion value of
[[Type]: break, [[Value]]: undefinedIf in fact this change was unintentional and broken when the algorithm conventions changed, then other places that might have been similarly broken should be inspected.