Skip to content

Erroneous usage of undefined type parameters isn't consistently reported #2791

@sungshik

Description

@sungshik

Describe the bug

In some cases, erroneous usage of undefined type parameters is reported (as expected). In other cases, it isn't. When it isn't, in some cases, errors downstream are reported. In other cases, they aren't.

To Reproduce

// -- Expected behavior --

alias List1[&T1]        = list[&U1]; // Error

// -- Unexpected behavior --

alias List2             = list[&U2]; // No error
alias List3[&T3 <: &U3] = list[&U3]; // No error
alias List4[&T1]        = list[&U3]; // No error. Moreover, "Go To Definition" suggests the def location of `&U3` (not a typo) is the location of the upper bound of `List3`.

List2[node] f2() {
    List2 l = [];

    l += 5;          // No error
    l += "foo";      // No error
    l += [5];        // No error
    l += ["foo"];    // No error
    l += [5, "foo"]; // No error
    
    int i = l[0]; // No error
    str s = l[1]; // No error

    return l;
}

List3[node] f3() {
    List3[bool] l = [];

    l += 5;          // Error
    l += "foo";      // Error
    l += [5];        // Error
    l += ["foo"];    // Error
    l += [5, "foo"]; // No error
    
    int i = l[0]; // No error
    str s = l[1]; // No error

    return l;
}

Expected behavior

  • Errors in the definitions of List2, List3, and List4.
  • The def location of &U3 in the definition of List4 cannot be the location of the upper bound of List3.
  • In the definition of f3, either for each addition to l an error, or for none.
  • In the definition of f3, errors in the assignments to i and s (i.e., it seems never safe to use those values as int and str without additional checks).
  • The same errors in the definition of f2 as in the definition of f3 (?)

Additional context

VS Code extension: 0.13.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions