Skip to content

Confusing error message if ADT type and constructor named alike #977

@mschwerhoff

Description

@mschwerhoff
type Pair adt {
    Pair { // Rename to, e.g. MkPair
        fst int
        snd int
    }
}

ghost
decreases
func test() Pair {
    return Pair{1, 2}
}
  • Just type Pair compiles fine
  • Return statement in func test() causes error: cannot assign literal to Pair
  • If ADT constructor is renamed, e.g. to MkPair, and return statement adjusted accordingly, the error disappears

Would be nice to

  • either report the name clash directly for the ADT declaration, with a suitable error message
  • or allow constructor name and type name to be equal (if their use can be disambiguated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions