Repository navigation
feat(t27b): plain enums as integer tags (Closes #6146) - #6254
Merged
Merged
Conversation
enum / enum(T) declarations with and without explicit values lower to integer tags. E.v, E::v and .v (with a result type), == and != on tags, ordering only where t27c writes @intFromEnum(a) < @intFromEnum(b), @intFromEnum, @enumFromInt (runtime: traps "invalid enum value", like Zig's safety check), @as(T, x), enum params, returns, fields, locals and module constants. Clean rejects with their own construct: EnumDecl(method), EnumDecl(non-exhaustive), EnumDecl(union), ExprSwitch, ExprEnumValue. corpus specs: pass 162 -> 165, pass_vacuous 278 -> 278, fail 2 -> 2, rejected 763 -> 760, mismatch 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
6 tasks
This was referenced Oct 4, 2026
Merged
This was referenced Oct 4, 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 #6146. Stacked on #6249 (slices), which is stacked on #6247 (arrays).
What
enum E { .. }andconst E = enum(T) { .. }, with and without explicit values. The tag type is mirrored from t27c's Zig backend:enum(T)uses T;E.v,E::v, and.vwherever anEis expected (args, returns, typed locals, struct fields, module constants,assert_eq,@as(E, .v)).==and!=compare tags. Ordering is accepted only where t27c writes@intFromEnum(a) < @intFromEnum(b)(one sideE.v).@intFromEnum, plus@as(T, x)in general.@enumFromInt:TrapKind::EnumTag), as Zig's safety check does.EnumDecl(method),EnumDecl(non-exhaustive),EnumDecl(union)(forunion(enum));ExprSwitch(t27b has no switch yet);ExprBinary(<) on enumfor two enum values;ExprEnumValuefor.vwith no result type;@enumFromInt;@intFromEnumof an auto-tagged (u2) enum used as a value (allowed in comparisons and where a wider integer is wanted).EnumTagtrap sites.Corpus (
t27b corpus specs, macOS arm64)EnumDeclwas the 📜 Canon Update: AGENTS_ALPHABET + AGENT_T_SKILL #1 first blocker (109 files) and is now gone from the list.AsmSectionKind_from_i8.t27: reference 8/8.HirBusPort_axi4_lite_slave.t27: reference 23/23.server/api.t27: the reference does not compile it, because an unused struct names an undeclared type. Zig catches that at AstGen; t27b lays out structs lazily, which predates this PR.Reference (t27c Zig backend) bugs found
const D: Dir = .east;is emitted asconst D: Dir;, so the value is dropped and the file fails with "variables must be initialized".var x: u8 = 1; x = f(x);is emitted withconst x = f(x);, so zig fails with "redeclaration of local variable".🤖 Generated with Claude Code