Skip to content

Commit

Permalink
match data[&T] against Tree if &T is a non-terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 21, 2023
1 parent e3b4411 commit 7d60d3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/org/rascalmpl/types/ModifySyntaxRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,14 @@ protected boolean isSubtypeOfAbstractData(Type type) {

@Override
public boolean match(Type matched, Map<Type, Type> 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);
}

Expand Down

0 comments on commit 7d60d3e

Please sign in to comment.