(leftOperand *ast.Expression, pos int, allowReturnTypeInArrowFunction bool)
| 4555 | } |
| 4556 | |
| 4557 | func (p *Parser) parseConditionalExpressionRest(leftOperand *ast.Expression, pos int, allowReturnTypeInArrowFunction bool) *ast.Expression { |
| 4558 | // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. |
| 4559 | questionToken := p.parseOptionalToken(ast.KindQuestionToken) |
| 4560 | if questionToken == nil { |
| 4561 | return leftOperand |
| 4562 | } |
| 4563 | // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and |
| 4564 | // we do not that for the 'whenFalse' part. |
| 4565 | saveContextFlags := p.contextFlags |
| 4566 | p.setContextFlags(ast.NodeFlagsDisallowInContext, false) |
| 4567 | trueExpression := p.parseAssignmentExpressionOrHigherWorker(false /*allowReturnTypeInArrowFunction*/) |
| 4568 | p.contextFlags = saveContextFlags |
| 4569 | colonToken := p.parseExpectedToken(ast.KindColonToken) |
| 4570 | var falseExpression *ast.Expression |
| 4571 | if ast.NodeIsPresent(colonToken) { |
| 4572 | falseExpression = p.parseAssignmentExpressionOrHigherWorker(allowReturnTypeInArrowFunction) |
| 4573 | } else { |
| 4574 | falseExpression = p.createMissingIdentifier() |
| 4575 | } |
| 4576 | return p.finishNode(p.factory.NewConditionalExpression(leftOperand, questionToken, trueExpression, colonToken, falseExpression), pos) |
| 4577 | } |
| 4578 | |
| 4579 | func (p *Parser) parseBinaryExpressionOrHigher(precedence ast.OperatorPrecedence) *ast.Expression { |
| 4580 | pos := p.nodePos() |
no test coverage detected