Browse Source

Allow 'in' in conditional expression's consequent

Dmitry Panov 2 years ago
parent
commit
5460598cfa
2 changed files with 3 additions and 3 deletions
  1. 3 0
      parser/expression.go
  2. 0 3
      tc39_test.go

+ 3 - 0
parser/expression.go

@@ -1169,7 +1169,10 @@ func (self *_parser) parseConditionalExpression() ast.Expression {
 
 
 	if self.token == token.QUESTION_MARK {
 	if self.token == token.QUESTION_MARK {
 		self.next()
 		self.next()
+		allowIn := self.scope.allowIn
+		self.scope.allowIn = true
 		consequent := self.parseAssignmentExpression()
 		consequent := self.parseAssignmentExpression()
+		self.scope.allowIn = allowIn
 		self.expect(token.COLON)
 		self.expect(token.COLON)
 		return &ast.ConditionalExpression{
 		return &ast.ConditionalExpression{
 			Test:       left,
 			Test:       left,

+ 0 - 3
tc39_test.go

@@ -190,9 +190,6 @@ var (
 
 
 		// FIXME bugs
 		// FIXME bugs
 
 
-		// 'in' in a branch
-		"test/language/expressions/conditional/in-branch-1.js": true,
-
 		// Left-hand side as a CoverParenthesizedExpression
 		// Left-hand side as a CoverParenthesizedExpression
 		"test/language/expressions/assignment/fn-name-lhs-cover.js": true,
 		"test/language/expressions/assignment/fn-name-lhs-cover.js": true,