You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comptime transform: a payload variant call folded to its shorthand no longer matches its pattern at run time #3016
Found on stack #3008 (layer compiler-admissions). ct_try_fold_type_call speculatively evaluates a Type.method(args) call with a known static receiver; once ct_build_value_tree learned to write a CV_ENUM with payload back as .Variant(payload), this program mismatched:
enum DbError:
NotFound(str, str)
Busy
enum AppError:
Db(DbError)
Io
fn main:
let g = AppError.Db(DbError.NotFound("users", "42"))
match g:
.Db(.NotFound(a, b)) => print(f"ok {a} {b}")
_ => print("MISMATCH")
prints MISMATCH when the call is folded, while the same text written as let f: AppError = .Db(.NotFound("users", "42")) matches on every compiler. So the folded tree differs from the parsed shorthand in something the match reads (the enum identity of the nested variant, or the payload layout the binding is given, #1836's type recording). The layer leaves such calls unfolded (ct_try_fold_type_call returns the node when the value is an enum with payload); the fold still serves a comptime block's result (const CIRCLE: Shape = .Circle(7), behav_2950_comptime_payload_variant). Route: --dump-typed of the folded unit against the parsed one, then lldb on ct_build_value_tree.
Activity
#2950: a payload variant call stays unfolded (#3016); the shorthand f…
#2950: the compiler's admissions: two comptime gaps closed, the rest …
#3016, #3032, #2946, #2976, #2949, #3051, #3005, #3001, #3017, #2521:…
ehartford commentedon Nov 7, 2026
Fixed in #3056 (merged as afbdbb1).