Skip to content

Union type: no warning for duplicate types #21240

@kraktus

Description

@kraktus

Compiler version

3.4.2

Minimized example

type Union = Int | Int

Output Error/Warning message

No warning

Suggested improvement

-- [E006] Union Duplicate Warning: ----------------
1 | Int | Int
  | ^^    ^^
  | `Int` declared twice in union, consider removing one occurence
1 warning found

I'm not sure if this is actionable as there may be cases where it'd be desirable, with generics for example

type IntOr[T] = Int | T

but at least for concrete types I think it'd be a good warning to declutter the code (mostly an issue with long unions, and/or type alias)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:lintingLinting warnings enabled with -W or -Xlintarea:reportingError reporting including formatting, implicit suggestions, etcarea:union-typesIssues tied to union types.better-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancementprio:low

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions