Repository navigation
fix!: name each enum case constant for its enum - #236
Open
robfischer1 wants to merge 1 commit into
Open
robfischer1 wants to merge 1 commit into
robfischer1 wants to merge 1 commit into
Conversation
WIT scopes a case name to its enum; gravity emitted every case as an
unqualified package constant. Two enums sharing a case name, or a case
sharing a type's name, then redeclared an identifier and the bindings
failed go vet:
enum_collisions.go:41:2: PeerSvid redeclared in this block
The identity lift had to spell its `via` cases `via-peer-svid`, ... to
dodge `credential-kind`'s `peer-svid`. Every case constant is now the
enum's Go name followed by the case's (ViaPeerSvid,
CredentialKindPeerSvid, ShapePoint beside the record Point), as Go
spells an enumerated constant (http.MethodGet). The enum's qualified
name is already unique (arcjet#197), so its constants are too.
BREAKING: every enum constant is renamed (Red becomes ColorRed). The
upstream examples' tests are updated, and the regressions WIT drops the
comment that called constant qualification out of scope. Qualifying
only colliding names, as arcjet#197 does for types, was rejected: a new enum
would then rename an existing enum's constants.
Tests: imports::tests::test_enum_case_constants_are_named_for_their_enum
(fails without the fix) and the new enum-collisions example
(TestSharedCaseNamesStayDistinct, TestCaseNamedLikeAType; without the
fix go vet fails with the error above).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIT scopes a case name to its enum, but gravity emitted every case as an unqualified package constant. Two enums sharing a case name, or a case sharing a type's name, failed
go vet:Every constant is now named after its enum, as
ColorRed, the way the Go standard library writeshttp.MethodGet.Breaking: every enum constant is renamed.
Qualifying only the colliding names, as #197 does for types, was rejected. With that rule, adding an enum later would rename another enum's constants.
Tests:
imports::tests::test_enum_case_constants_are_named_for_their_enumenum-collisionsexample🤖 Generated with Claude Code
https://claude.ai/code/session_01K99bnsYaj3w4MMWSF5hTMu