public override IPExpr VisitChooseExpr(PParser.ChooseExprContext context) { // if choose is without an argument then its a choose boolean if (context.expr() == null) { return(new ChooseExpr(context, null, PrimitiveType.Bool)); } IPExpr subExpr = Visit(context.expr()); PLanguageType subExprType = subExpr.Type; switch (subExprType.Canonicalize()) { case SequenceType seqType: return(new ChooseExpr(context, subExpr, seqType.ElementType)); case SetType setType: return(new ChooseExpr(context, subExpr, setType.ElementType)); case PrimitiveType primType when primType.IsSameTypeAs(PrimitiveType.Int): return(new ChooseExpr(context, subExpr, PrimitiveType.Int)); default: throw handler.IllegalChooseSubExprType(context, subExprType); } }