Skip to content

Commit

Permalink
added a failing test for data[&T] matching against parse tree
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 22, 2023
1 parent 2cdfcdc commit a0c597c
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,20 @@ test bool namePreservation2() {
// assignment and function return types would fail if we had a bug here.
return sort("A") == typeOf(x);
}


test bool dataMatchesSyntaxTreesToo1() {
return data[Tree] _ := [syntax[A]] "a";
}

@expect{UnexpectedType}
test bool dataMatchesSyntaxTreesToo2() {
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] shoultNotAssignStatically = castIt([syntax[A]] "a");

// we are never supposed to end up here
return false;
}

0 comments on commit a0c597c

Please sign in to comment.