Skip to content

Commit

Permalink
Added new compiler issue as ignored test
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 23, 2023
1 parent dbdaa36 commit b684d0e
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module lang::rascal::tests::basic::CompilerIssues::VariableBoundInConditionalInComprehension

data AType = avalue() | aparameter(str pname, AType bound);

// The original code from CollectDeclaration:
// The issue is that "typeVarBounds[tvname2]" is moved before the comprehension (because the variable "tvname2" has to be declared)
// and then gives IndexOutOfBounds error

map[str, AType] propagateParams(map[str,AType] typeVarBounds){
return (tvname : (aparameter(tvname2, _) := typeVarBounds[tvname]) ? typeVarBounds[tvname2] : typeVarBounds[tvname] | tvname <- typeVarBounds);}

// The following equivalent code is compiled correcly:
//map[str, AType] propagateParams(map[str,AType] typeVarBounds){
// AType find(str tvname) = (aparameter(tvname2, _) := typeVarBounds[tvname]) ? typeVarBounds[tvname2] : typeVarBounds[tvname] ;
// return (tvname : find(tvname) | tvname <- typeVarBounds);
//}

@ignoreCompiler{Compiled code crahes with IndexOutOfBounds}
test bool variableBoundInConditionalInComprehension() = propagateParams(("T":avalue())) == ("T" : avalue());

0 comments on commit b684d0e

Please sign in to comment.