Skip to content

Fix enum variations not resolved for cross-package enum types#110

Merged
shane-tw merged 1 commit intomasterfrom
fix/cross-package-enum
Apr 23, 2026
Merged

Fix enum variations not resolved for cross-package enum types#110
shane-tw merged 1 commit intomasterfrom
fix/cross-package-enum

Conversation

@shane-tw
Copy link
Copy Markdown
Contributor

@shane-tw shane-tw commented Apr 23, 2026

Basically the automatic enum handling introduced in this PR wasn't working if it was a cross-package enum.

When a field annotated with {enum} has a type from another package (e.g. pkg.SomeType), getEnumVariations was never called with the correct type name. The SelectorExpr branch called canonicalType which resolved the type to its underlying primitive and then jumped back via goto start; the re-entry then called getEnumVariations with the primitive name ("string") rather than the original type name ("SomeType"), so no constants were ever matched.

Fix: call getEnumVariations with the original pkg and type name before executing goto start in the SelectorExpr branch, mirroring what the Ident branch already does.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 23, 2026

Coverage Report for CI Build 24848043446

Coverage increased (+0.3%) to 53.278%

Details

  • Coverage increased (+0.3%) from the base build.
  • Patch coverage: 5 uncovered changes across 1 file (13 of 18 lines covered, 72.22%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
docparse/jsonschema.go 18 13 72.22%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
docparse/jsonschema.go 1 45.57%

Coverage Stats

Coverage Status
Relevant Lines: 2181
Covered Lines: 1162
Line Coverage: 53.28%
Coverage Strength: 45.51 hits per line

💛 - Coveralls

@shane-tw shane-tw force-pushed the fix/cross-package-enum branch from d8ea766 to e4361bf Compare April 23, 2026 16:58
When a field annotated with {enum} has a type from another package
(e.g. `pkg.SomeType`), getEnumVariations was never called with the
correct type name. The SelectorExpr branch called canonicalType which
resolved the type to its underlying primitive and then jumped back via
goto start; the re-entry then called getEnumVariations with the
primitive name ("string") rather than the original type name
("SomeType"), so no constants were ever matched.

Fix: call getEnumVariations with the original pkg and type name before
executing goto start in the SelectorExpr branch, mirroring what the
Ident branch already does.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shane-tw shane-tw force-pushed the fix/cross-package-enum branch from e4361bf to 94f070e Compare April 23, 2026 17:01
@shane-tw shane-tw merged commit 95d769c into master Apr 23, 2026
3 checks passed
@shane-tw shane-tw deleted the fix/cross-package-enum branch April 23, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants