You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compiler uses the match function of the type checker (from the TypeInstantiation module) to compute type parameter bindings and instantiate types. To do so, it creates a tuple of formal parameter types and a tuple of argument types, and in this case the match function throws invalidMatch exception (see defaultMatch). This becomes also a type checking issue, for example, in the following case:
list[&U] mapper(tuple[list[&T] lst, &U (&T) fun] t) = [ t.fun(elem) | elem <- t.lst ];
value tstMapper(list[int] L) {
int incr(int x) { return x + 1; };
return mapper(<L, incr>);
}
error("Could not instantiate type variables in type fun list[&U \<: value](tuple[list[&T \<: value] lst, fun &U \<: value(&T \<: value) fun]) with argument types (tuple[list[int], fun int(int)])",|rascal:///experiments/Compiler/Examples/NestedFunctions5.rsc|(259,17,<10,9>,<10,26>))
|rascal://experiments::Compiler::Rascal2muRascal::RascalModule|(2652,25,<80,12>,<80,37>): "Module contains errors!"
Will do. I think I'm just going to have to rewrite the match functionality, it's too brittle with these cases (the root problem is that a subtyping check is performed to see if the parameterized type and the actual type can be matched, but this works for all cases except functions, which, because of contravariance, are generally supertypes of the subject).
I've tested this with a number of Rascal libraries and this appears to be working fine, but please test it within the compiler as well, this was a fairly big change in how parameterized types are matched.
gives
The text was updated successfully, but these errors were encountered: