Repository navigation
t27core: enums, byte-identical to gen-c (Closes #8004) - #8007
Merged
Merged
Conversation
P2 slice 2 of epic #5980. The self-hosted core accepts enum declarations (`enum E [(T)] { ... }` and `const|let E = enum [(T)] { ... };`), enum types wherever a struct type stands, members written `E.M`, `E::M` and `.M`, `.M` switch labels, a switch without `else` that names every member of one enum once, and arrays of enums repeating `E.M`. gen-c's Enums section and upper-cased constants are reproduced byte for byte. New code E_ENUM (13). Refused, each with a fixture: a member matched only by case or with no single owner, a name spelling an emitted constant, a local named like an enum (#8001); a member value that is not one number (#8002); `const D: E = .M;`, `[_]E{.M} ** N`, a non-exhaustive or duplicated enum switch (#8003); an empty enum; colliding constants. t27core_ddc.t27 is repinned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
enabled auto-merge (squash)
October 9, 2026 05:32
4 of 6 tasks
Contributor
This was referenced Oct 9, 2026
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.
Closes #8004. Part of #5980 (P2: enums). Follows #8000 (structs).
What the core accepts now
Probed against
t27c gen-con master 321ced0. Byte-identical with gen-c:[pub] enum E [(SCALAR)] { a, b = N, c = -N, ... }and[pub] const|let E = enum [(SCALAR)] { ... };. gen-c drops the tag type, since a C enum is an int.typedef enum { E_A, E_B = 5, ... } E;.E.a,E::aand.a, written as gen-c's upper-cased constantE_A. The same holds in a const value (const D: E = E::a;) and in struct literals..a =>in a switch with anelse;elsewhose arms name every member of one enum exactly once. gen-c's closing: 0is never reached there.E.a/E::a, which gen-c writes as a range, as it does a number.What it refuses (gen-c exits 0 on each)
e13_enum_member_no_single_owner.xwith two owners becomes a bareX, here the const 3 (#8001)e13_enum_member_case_inferred,e13_enum_member_case_dotted.redandE.BLUEmatchRedandblueonce upper-cased; Zig has no such member (#8001)e5_enum_constant_spelled_by_paramMODE_ONhides the constant and C returns it (#8001)e5_enum_shadowed_by_localE.onas the member whatever bindsE(#8001)e13_enum_value_expressionp = 1 + 2givesG_P = 1, G_2: a new member (#8002)e13_enum_value_separator1_000is written as spelled (#8002)e7_enum_inferred_constconst D: E = .on;is never emitted (#8003)e9_enum_repeat_inferred[_]E{.on} ** 2becomes{0}, the first member (#8003)e2_enum_switch_not_exhaustiveelse, a missing member reads 0; Zig refuses (#8003)e2_enum_switch_duplicate_labele13_enum_constants_collideaandAare one C constante13_enum_emptyZig backend defect found on the way: #8006.
t27c genwritese as u8on an enum as@intCast(e), which Zig rejects; t27b refuses the cast too.accept/enum_cast.t27pins the shape for C, andaccept/enum_values.t27runs on all three routes. The core itself does not cast an enum.Lines by file
specs/compiler/core/t27core.t27specs/compiler/core/t27core_ddc.t27bootstrap/tests/fixtures/core_selfhost/**/*.t27On the t27c lab, master's
gen/c/policy/own_language.cwithorigin/master:tools/policy/foreign-exceptions.txtgivescheck_budgetexit 0 andcheck_allexit 0.Lab evidence
t27c lab, with t27c built from 321ced0 plus this branch.
compiler.rsis unchanged.core(core.t27) == gen-c(core.t27)cargo test --release -p t27c --test core_selfhostt27c test-report)t27core_ddc1/1,enum_values2/2;enum_castis BLOCKED by #8006t27core_ddc1/1,enum_values2/2;enum_castis refused by t27b (unsupported cast)t27core_ddc.t27is repinned:d9905301...a649.318eda9c...846f.🤖 Generated with Claude Code