Skip to content

Commit

Permalink
added test for upcasting data[&T] to data[Tree] when it matches a non…
Browse files Browse the repository at this point in the history
…-terminal
  • Loading branch information
jurgenvinju committed Nov 23, 2023
1 parent 16a6498 commit 53c750e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ test bool dataMatchesSyntaxTreesToo1() {
return data[Tree] _ := [syntax[A]] "a";
}

@expect{UnexpectedType}
@expected{UnexpectedType}
test bool dataMatchesSyntaxTreesToo2() {
// even though this is a type-preserving function,
// it will up-cast &T to Tree if called with a non-terminal
data[&T] castIt(data[&T] i) = i;

// here &T should be bound to adt("Tree",[]) and not to sort("A"), statically.
// but I can't write a negative test for the type-checker here I think..

syntax[A] shouldNotAssignStatically = castIt([syntax[A]] "a");

// we are never supposed to end up here
Expand Down

0 comments on commit 53c750e

Please sign in to comment.