Skip to content

No error or warning on duplicate CompiledName #4737

Closed

Description

@kerams

https://fable.io/repl/#?code=C4TwDgpgBAGlC8BYAUFNUA+UDaAeAwgPYC2YAlgDYQAmAcgIbHQBEAZq8wHwC6UAginSYcBEuSp1GLdl14AhIA&html=Q&css=Q

type X =
    | [<CompiledName "ff">] A
    | [<CompiledName "ff">] B

Fable, unlike .NET, honours this attribute on union cases. However, it doesn't verify that the names are unique. At the very least I would like to see a warning if there are valid use cases for this, otherwise an error.

Activity

  1. MangelMaxime commented on Jul 8, 2026

    @MangelMaxime
    Member

    I am almost certain that I saw some JavaScript libraries that used different value of enum to map to the same value.

    In those scenarios it is normal case and does not need a warning or error message as they would be false positive.

    Because of that I am unsure if this is something we can improve.

  2. kerams commented on Jul 8, 2026

    @kerams
    ContributorAuthor

    You can disable a warning, but you can't conjure one out of thin air:). I am starting to make heavy use of CompiledName and I want compile-time assurance that I didn't make a mistake in duplicating labels.

  3. MangelMaxime commented on Jul 8, 2026

    @MangelMaxime
    Member

    You can disable a warning, but you can't conjure one out of thin air

    Fable does not have this feature (yet)

    Also, I confused CompiledName with CompiledValue which is something else.

    And indeed, I think have 2 enum cases name being the same is probably strange and should be reported as error. If there are issues with that in the future, we can reduce it to a warning.

  4. MangelMaxime commented on Jul 16, 2026

    @MangelMaxime
    Member

    While working on the fix for this issue I found one Fable library using this feature:

    Fable.React.Props.fs

    type Prop =
        | Key of string
        | Ref of (Element->unit)
        /// To be used in combination with `useRef` hook
        | [<System.Obsolete("Use RefValue")>] [<CompiledName("ref")>] RefHook of IRefHook<Element option>
        | [<CompiledName("ref")>] RefValue of IRefValue<Element option>
        interface IHTMLProp

    I am still doing more investigation

  5. shayanhabibi commented on Oct 15, 2026

    @shayanhabibi
    Contributor

    I'm also utilising this as a feature for #5075 , but the error could be ignored if there are other attributes attached to one of the duplicate cases? That would protect Fable.React.Props and my use case too.

  6. MangelMaxime commented on Oct 22, 2026

    @MangelMaxime
    Member

    This has been released in 5.24.0

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