From 730647c9ff68d094743e33f2e857844ab8d27814 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 14:03:22 +0100 Subject: [PATCH 1/4] Fixed two incorrect types in BasicType --- src/org/rascalmpl/semantics/dynamic/BasicType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/semantics/dynamic/BasicType.java b/src/org/rascalmpl/semantics/dynamic/BasicType.java index 805cc272490..bfe2185d5a1 100644 --- a/src/org/rascalmpl/semantics/dynamic/BasicType.java +++ b/src/org/rascalmpl/semantics/dynamic/BasicType.java @@ -139,7 +139,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .integerType(); + .rationalType(); } throw new NonWellformedType("rat cannot have type arguments.", this); @@ -419,7 +419,7 @@ public Set(ISourceLocation __param1, IConstructor tree) { @Override public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().isBottom()) { - return TF.listType(TF.voidType()); + return TF.setType(TF.voidType()); } if (__eval.__getTypeArgument().getArity() == 1) { From 78a606798d571e735493b38f1046c9ede350293b Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 14:05:26 +0100 Subject: [PATCH 2/4] Consistently use the same TypeFactory throughout BasicType --- .../semantics/dynamic/BasicType.java | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/src/org/rascalmpl/semantics/dynamic/BasicType.java b/src/org/rascalmpl/semantics/dynamic/BasicType.java index bfe2185d5a1..25d837551eb 100644 --- a/src/org/rascalmpl/semantics/dynamic/BasicType.java +++ b/src/org/rascalmpl/semantics/dynamic/BasicType.java @@ -58,8 +58,7 @@ public Bool(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .boolType(); + return TF.boolType(); } throw new NonWellformedType( "bool cannot have type arguments.", this); @@ -85,8 +84,7 @@ public DateTime(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .dateTimeType(); + return TF.dateTimeType(); } throw new NonWellformedType( "datetime cannot have type arguments.", this); @@ -110,8 +108,7 @@ public Int(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .integerType(); + return TF.integerType(); } throw new NonWellformedType("int cannot have type arguments.", this); @@ -138,8 +135,7 @@ public Rational(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .rationalType(); + return TF.rationalType(); } throw new NonWellformedType("rat cannot have type arguments.", this); @@ -197,8 +193,7 @@ public Loc(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .sourceLocationType(); + return TF.sourceLocationType(); } throw new NonWellformedType("loc cannot have type arguments.", this); @@ -257,8 +252,7 @@ public Node(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .nodeType(); + return TF.nodeType(); } throw new NonWellformedType( "node cannot have type arguments.", this); @@ -284,8 +278,7 @@ public Num(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .numberType(); + return TF.numberType(); } throw new NonWellformedType("num cannot have type arguments.", this); @@ -311,8 +304,7 @@ public Real(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .realType(); + return TF.realType(); } throw new NonWellformedType( "real cannot have type arguments.", this); @@ -335,15 +327,13 @@ public Type(ISourceLocation __param1, IConstructor tree) { @Override public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { + var rtf = org.rascalmpl.types.RascalTypeFactory.getInstance(); if (__eval.__getTypeArgument().isBottom()) { - return org.rascalmpl.types.RascalTypeFactory - .getInstance().reifiedType(TF.voidType()); + return rtf.reifiedType(TF.voidType()); } if (__eval.__getTypeArgument().getArity() == 1) { - return org.rascalmpl.types.RascalTypeFactory - .getInstance().reifiedType( - __eval.__getTypeArgument().getFieldType(0)); + return rtf.reifiedType(__eval.__getTypeArgument().getFieldType(0)); } throw new NonWellformedType( "type should have exactly one type argument, like type[value]", @@ -369,8 +359,7 @@ public Relation(ISourceLocation __param1, IConstructor tree) { @Override public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .relTypeFromTuple(__eval.__getTypeArgument()); + return TF.relTypeFromTuple(__eval.__getTypeArgument()); } @@ -394,8 +383,7 @@ public ListRelation(ISourceLocation __param1, IConstructor tree) { @Override public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .lrelTypeFromTuple(__eval.__getTypeArgument()); + return TF.lrelTypeFromTuple(__eval.__getTypeArgument()); } @@ -423,8 +411,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { } if (__eval.__getTypeArgument().getArity() == 1) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .setType(__eval.__getTypeArgument().getFieldType(0)); + return TF.setType(__eval.__getTypeArgument().getFieldType(0)); } throw new NonWellformedType( "set should have exactly one type argument, like set[value]", @@ -452,8 +439,7 @@ public String(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .stringType(); + return TF.stringType(); } throw new NonWellformedType( "string cannot have type arguments.", this); @@ -502,8 +488,7 @@ public Value(ISourceLocation __param1, IConstructor tree) { public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .valueType(); + return TF.valueType(); } throw new NonWellformedType( "value cannot have type arguments.", this); @@ -527,8 +512,7 @@ public Void(ISourceLocation __param1, IConstructor tree) { @Override public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { - return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf() - .voidType(); + return TF.voidType(); } throw new NonWellformedType( "void cannot have type arguments.", this); From 82735c3761f5113f1b29cd3d47ef37ef6541cf1e Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 14:08:37 +0100 Subject: [PATCH 3/4] Condensed exceptions a bit in BasicType --- .../semantics/dynamic/BasicType.java | 79 ++++++------------- 1 file changed, 23 insertions(+), 56 deletions(-) diff --git a/src/org/rascalmpl/semantics/dynamic/BasicType.java b/src/org/rascalmpl/semantics/dynamic/BasicType.java index 25d837551eb..e3e38e07a0e 100644 --- a/src/org/rascalmpl/semantics/dynamic/BasicType.java +++ b/src/org/rascalmpl/semantics/dynamic/BasicType.java @@ -41,8 +41,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "bag should have one type argument, like bag[value].", this); + throw new NonWellformedType("bag should have one type argument, like bag[value].", this); } @@ -60,8 +59,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.boolType(); } - throw new NonWellformedType( - "bool cannot have type arguments.", this); + throw new NonWellformedType("bool cannot have type arguments.", this); } @@ -86,8 +84,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.dateTimeType(); } - throw new NonWellformedType( - "datetime cannot have type arguments.", this); + throw new NonWellformedType("datetime cannot have type arguments.", this); } @@ -110,8 +107,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.integerType(); } - throw new NonWellformedType("int cannot have type arguments.", - this); + throw new NonWellformedType("int cannot have type arguments.", this); } @@ -137,8 +133,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.rationalType(); } - throw new NonWellformedType("rat cannot have type arguments.", - this); + throw new NonWellformedType("rat cannot have type arguments.", this); } @@ -168,17 +163,13 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { return TF.listType(__eval.__getTypeArgument().getFieldType(0)); } - throw new NonWellformedType( - "list should have exactly one type argument, like list[value]", - this); + throw new NonWellformedType("list should have exactly one type argument, like list[value]", this); } @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "list should have one type argument, like list[value].", - this); + throw new NonWellformedType("list should have one type argument, like list[value].", this); } } @@ -195,8 +186,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.sourceLocationType(); } - throw new NonWellformedType("loc cannot have type arguments.", - this); + throw new NonWellformedType("loc cannot have type arguments.", this); } @@ -225,18 +215,14 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { return TF.mapTypeFromTuple(__eval.__getTypeArgument()); } - throw new NonWellformedType( - "map should have exactly two type arguments, like map[value,value]", - this); + throw new NonWellformedType("map should have exactly two type arguments, like map[value,value]", this); } @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "map should have at two type arguments, like map[value,value].", - this); + throw new NonWellformedType("map should have at two type arguments, like map[value,value].", this); } @@ -254,8 +240,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.nodeType(); } - throw new NonWellformedType( - "node cannot have type arguments.", this); + throw new NonWellformedType("node cannot have type arguments.", this); } @@ -280,8 +265,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.numberType(); } - throw new NonWellformedType("num cannot have type arguments.", - this); + throw new NonWellformedType("num cannot have type arguments.", this); } @@ -306,8 +290,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.realType(); } - throw new NonWellformedType( - "real cannot have type arguments.", this); + throw new NonWellformedType("real cannot have type arguments.", this); } @@ -335,17 +318,13 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 1) { return rtf.reifiedType(__eval.__getTypeArgument().getFieldType(0)); } - throw new NonWellformedType( - "type should have exactly one type argument, like type[value]", - this); + throw new NonWellformedType("type should have exactly one type argument, like type[value]", this); } @Override public io.usethesource.vallang.type.Type typeOf(Environment env, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "type should have at one type argument, like type[value].", - this); + throw new NonWellformedType("type should have at one type argument, like type[value].", this); } } @@ -366,9 +345,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "rel should have at least one type argument, like rel[value,value].", - this); + throw new NonWellformedType("rel should have at least one type argument, like rel[value,value].", this); } @@ -390,9 +367,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "lrel should have at least one type argument, like lrel[value,value].", - this); + throw new NonWellformedType("lrel should have at least one type argument, like lrel[value,value].", this); } @@ -413,17 +388,14 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 1) { return TF.setType(__eval.__getTypeArgument().getFieldType(0)); } - throw new NonWellformedType( - "set should have exactly one type argument, like set[value]", - this); + throw new NonWellformedType("set should have exactly one type argument, like set[value]", this); } @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "set should have one type argument, like set[value].", this); + throw new NonWellformedType("set should have one type argument, like set[value].", this); } @@ -441,8 +413,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.stringType(); } - throw new NonWellformedType( - "string cannot have type arguments.", this); + throw new NonWellformedType("string cannot have type arguments.", this); } @@ -470,9 +441,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { @Override public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator> eval, boolean instantiateTypeParameters) { - throw new NonWellformedType( - "tuple should have type arguments, like tuple[value,value].", - this); + throw new NonWellformedType("tuple should have type arguments, like tuple[value,value].", this); } @@ -490,8 +459,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.valueType(); } - throw new NonWellformedType( - "value cannot have type arguments.", this); + throw new NonWellformedType("value cannot have type arguments.", this); } @@ -514,8 +482,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { if (__eval.__getTypeArgument().getArity() == 0) { return TF.voidType(); } - throw new NonWellformedType( - "void cannot have type arguments.", this); + throw new NonWellformedType("void cannot have type arguments.", this); } @Override From 75dfe25c555fe8831fee91a679e2a083e9323124 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 14:09:33 +0100 Subject: [PATCH 4/4] Consistently use isBottom instead of a comparison to VoidType --- src/org/rascalmpl/semantics/dynamic/BasicType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/semantics/dynamic/BasicType.java b/src/org/rascalmpl/semantics/dynamic/BasicType.java index e3e38e07a0e..9a168f8e310 100644 --- a/src/org/rascalmpl/semantics/dynamic/BasicType.java +++ b/src/org/rascalmpl/semantics/dynamic/BasicType.java @@ -155,7 +155,7 @@ public List(ISourceLocation __param1, IConstructor tree) { @Override public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) { - if (__eval.__getTypeArgument() == TF.voidType()) { + if (__eval.__getTypeArgument().isBottom()) { return TF.listType(TF.voidType()); }