Skip to content

Renaming an enum used as a map's keyType leaves the key type pointing at the old name, so the schema stops validating #337

Open

Description

@matt-edmondson

What's wrong

#311 (for #300) added Array.KeyType, so a map can be keyed by a primitive or an enum. The rename cascade from #315 (for #222) finds a type's nested types through ExpandType, and that method only descends into ElementType:

As a result, TryRenameEnum updates every other reference to the enum except a map's keyType. The two PRs merged in the same batch, and neither covers the other.

Reproduction (verified)

  1. Create an enum Slot with the value Head.
  2. Create a class Inv with a member Items: Array { container: "map", elementType: String, keyType: Enum(Slot) }.
  3. schema.Validate() reports no issues.
  4. schema.TryRenameEnum(slot, "Slot2") returns true.
  5. schema.Validate() now reports Enum type references unknown enum 'Slot'.

Generation is then refused until the file is fixed by hand. Renaming the enum in the editor tree goes through the same code path.

Fix / acceptance criteria

  • ExpandType, and anything else that enumerates nested types, yields Array.KeyType when it is set.
  • Add a test: renaming an enum used as a map keyType repoints the key type, and validation stays clean.
  • The C# generator's Dictionary<TKey, …> spelling uses the new enum name.

Activity

  1. matt-edmondson commented on Oct 25, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions