rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Type-checker oversees fact about top-level type of case statement

Open jurgenvinju opened this issue 3 years ago • 1 comments

Describe the bug

data Symbol = \int();
data Statement = \if();

data S = label(Statement x, int y);
data T = label(Symbol x, str y);

value f(S s) {
    switch (s) {
        case label(_, x) : return x;
    }

    return "";
}

The case label resolves to both the T and the S. In complex cases this leads to spurious static errors (happened in Clair), while there is no error. Because s is a S the case label constructor should resolve only to the label constructor of the S sort.

jurgenvinju avatar Jul 01 '22 09:07 jurgenvinju

when I put label(Symbol _, _) the type-checker also misses errors, since that constructor it could never be.

jurgenvinju avatar Jul 01 '22 09:07 jurgenvinju