Skip to content

Commit 5e952e3

Browse files
author
Kevin Smith
committed
Allow "in" in the middle operand of ternaries
1 parent 630f662 commit 5e952e3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Parser/Parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9225,7 +9225,7 @@ ParseNodePtr Parser::ParseExpr(int oplMin,
92259225
// Special case the "?:" operator
92269226
if (nop == knopQmark)
92279227
{
9228-
pnodeT = ParseExpr<buildAST>(koplAsg, NULL, fAllowIn);
9228+
pnodeT = ParseExpr<buildAST>(koplAsg, NULL, TRUE);
92299229
ChkCurTok(tkColon, ERRnoColon);
92309230
ParseNodePtr pnodeT2 = ParseExpr<buildAST>(koplAsg, NULL, fAllowIn, 0, nullptr, nullptr, nullptr, nullptr, false, nullptr, plastRParen);
92319231
if (buildAST)

test/Basics/TernaryOperator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ WScript.Echo(cond ? "True" : "False");
1010
WScript.Echo("Setting condition to false...");
1111
cond = false;
1212
WScript.Echo(cond ? "True" : "False");
13+
14+
try {
15+
for (1 ? 'x' in {} : 0;;) break;
16+
} catch {
17+
WScript.Echo("In expression should be allowed in true part");
18+
}

0 commit comments

Comments
 (0)