Skip to content

Duplicate enum/error variant names are accepted silently (enum E: A, A compiles) #1344

Closed

Description

@ehartford

A type declaration may list the same variant name twice and nothing reports it. Found while implementing D57 (§10.9 combined error E from A = form), whose own wrapper-vs-written collision is now an error. The general duplicate is still silent.

Repro (seed and stage1 of branch error-from-with-variants):

enum E:
    A
    A

fn main:
    let e = E.A
    match e:
        .A => print("a")

with run prints a, rc 0. error E = | A | A passes with check the same way. Also error E from DbError, DbError generates two Db wrappers.

Expected: a compile-time error naming the variant and the declaration. E.A has two meanings and the compiler picks one without saying so. The spec has no sentence about duplicate variant names, so the diagnostic wording is Eric's call. A duplicate is never meaningful, so this looks like a missing check, not a new rule.

Workaround: none needed. No known program depends on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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