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
An error sometimes occurs when a (non-keyword) parameter of a function type has a name. The occurrence of the error seems to depend on whether the type of the parameter is user-defined or builtin.
rascal>alias LIST[&T] = list[&T];
ok
rascal>int(LIST[int]) HEAD1 = int(LIST[int] xs) { return xs[0]; };
int (LIST[int]): function(|prompt:///|(26,35,<1,26>,<1,61>))
rascal>int(LIST[int] xs) HEAD2 = int(LIST[int] xs) { return xs[0]; };
|prompt:///|(18,43,<1,18>,<1,61>): Expected int (LIST[int] xs), but got int (LIST[int])
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UnexpectedType|
ok
rascal>int(LIST[int] ys) HEAD3 = int(LIST[int] xs) { return xs[0]; };
|prompt:///|(18,43,<1,18>,<1,61>): Expected int (LIST[int] ys), but got int (LIST[int])
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UnexpectedType|
ok
Expected behavior
Either both Examples 1/2 succeed, or both fail
When put in a module, the type checker succeeds for all of head1, head2, head3, HEAD1, HEAD2, and HEAD3, so the more detailed expectation would be that both Examples 1/2 succeed (i.e., the name of the argument is not part of the type)
The text was updated successfully, but these errors were encountered:
The subtype conputation in the Interpreter goes through a big forwarding and multiple nesting levels of the "double dispatch" design pattern to resolve all the different cases.
Handling aliases in there is quirky because aliases are type equivalences (and thus have commutativity for subtype unlike the other type constructors).
My hunch would be that aliases were not considered for the variance (co- and contra) of function argument types. At least not in all the right places.
Describe the bug
An error sometimes occurs when a (non-keyword) parameter of a function type has a name. The occurrence of the error seems to depend on whether the type of the parameter is user-defined or builtin.
To Reproduce
Example 1 (succeeds):
Example 2 (fails):
Expected behavior
head1
,head2
,head3
,HEAD1
,HEAD2
, andHEAD3
, so the more detailed expectation would be that both Examples 1/2 succeed (i.e., the name of the argument is not part of the type)The text was updated successfully, but these errors were encountered: