rascal
rascal copied to clipboard
Interpreter does not support sub-typing for regular symbols with type parameters
Describe the bug
This is never called:
int size({&E &S}* l) = (0 | it + 1 | _ <- l);
because the parameter type does not match:
rascal>size((Pattern) `f(1,2,3)`.arguments)
|prompt:///|(5,30,<1,5>,<1,35>): CallFailed([appl(
regular(\iter-star-seps(
sort("Pattern"),
[
This is already witnessed by a simpler assignment:
rascal>{&Elem &Sep}* l = (Pattern) `f(1,2,3)`.arguments;
)
|prompt:///|(14,34,<1,14>,<1,48>): Expected {&Elem &Sep}*, but got {Pattern ","}*
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UnexpectedType|
This is problematic. If you want to deal with syntax lists the support in Rascal is (too) minimal.
I need functions like size and zip2.
It looks like the .isSubtype method on NonterminalType is broken.
if (SymbolAdapter.isParameter(otherSym)) {
RascalType bound = (RascalType) RTF.nonTerminalType((IConstructor) otherSym.get("bound"));
return isSubtypeOf(bound);
}
This returns a bound Tree but not an adt with the name "Tree" but a syntax sort named "Tree". That is causing the trouble. So the question is how this bound dropped in.