Skip to content

When "OneOf" types get too long, they cause a corruption error in the Elm compiler cache #205

@lucamug

Description

@lucamug

We had a case where we have several errors types that get concatendated with "or" as part of OneOf case.

The compilation from scratch of the generated Elm code works fine, but a re-compilation generated this error:

Image

It seems that the Elm compiler is not able to read back the cached files when type names are too long.

The solution that we adopted is to shorten these names with an hash.

Before:

type_ =
    Common.OneOf
        (names
            |> List.map fixOneOfName
            |> String.join "_or_"
        )
        sortedVariants

After:

type_ =
    Common.OneOf
        (names
            |> List.map fixOneOfName
            |> String.join "_or_"
            |> (\s -> "OneOf" ++ String.fromInt (Murmur3.hashString 1234 s))
        )
        sortedVariants

I will send a PR as example, but there are probably more elegant solutions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions