From 7d60d3ec6a8cdd1c44110067b318e83d39d723e1 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 21 Nov 2023 14:55:26 +0100 Subject: [PATCH] match data[&T] against Tree if &T is a non-terminal --- src/org/rascalmpl/types/ModifySyntaxRole.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/types/ModifySyntaxRole.java b/src/org/rascalmpl/types/ModifySyntaxRole.java index efb81db96f9..ae3b0a907d9 100644 --- a/src/org/rascalmpl/types/ModifySyntaxRole.java +++ b/src/org/rascalmpl/types/ModifySyntaxRole.java @@ -705,7 +705,14 @@ protected boolean isSubtypeOfAbstractData(Type type) { @Override public boolean match(Type matched, Map bindings) throws FactTypeUseException { - if (matched.isAbstractData() || matched.isBottom()) { + if (matched instanceof NonTerminalType) { + // here a `syntax` or `lexical` or `keyword` or `layout` would match against a + // literal data[&T], and we need the &T to bind with `Tree` and not `Statement` or + // some non-terminal name. Note that this is correct because `Tree` is an + // algebraic `data` type. + return arg.match(RascalValueFactory.Tree, bindings); + } + else if (matched.isAbstractData() || matched.isBottom()) { return arg.match(matched, bindings); }