Exemple #1
0
        public override IPExpr VisitNamedTupleAccessExpr(PParser.NamedTupleAccessExprContext context)
        {
            var subExpr = Visit(context.expr());

            if (!(subExpr.Type.Canonicalize() is NamedTupleType tuple))
            {
                throw handler.TypeMismatch(subExpr, TypeKind.NamedTuple);
            }
            var fieldName = context.field.GetText();

            if (!tuple.LookupEntry(fieldName, out var entry))
            {
                throw handler.MissingNamedTupleEntry(context.field, tuple);
            }
            return(new NamedTupleAccessExpr(context, subExpr, entry));
        }
 public override object VisitNamedTupleAccessExpr(PParser.NamedTupleAccessExprContext context)
 {
     return(null);
 }