fix(0118): cast accepts compound type args; compound type literals are first-class Type values

This commit is contained in:
agra
2026-06-11 14:09:22 +03:00
parent c229f697bd
commit 03dc10bba3
7 changed files with 77 additions and 17 deletions

View File

@@ -2021,6 +2021,25 @@ pub fn lowerExpr(self: *Lowering, node: *const Node) Ref {
break :blk self.emitError(te.name, node.span);
},
// Compound type literals (`*T`, `[]T`, `[*]T`, `?T`, `[N]T`, fn types)
// in expression position are first-class `Type` values, exactly like
// the named form above (`t : Type = *s64;` ↔ `t : Type = f64;`). Also
// the path a static `cast(*s64) v` type argument takes — call args are
// lowered before the cast handler inspects the AST (issue 0118).
.pointer_type_expr,
.many_pointer_type_expr,
.slice_type_expr,
.optional_type_expr,
.array_type_expr,
.function_type_expr,
=> blk: {
const ty = self.resolveTypeWithBindings(node);
// The resolver diagnosed any unresolved leaf; don't mint a Type
// value around the failure sentinel.
if (ty == .unresolved) break :blk self.emitError("unknown_expr", node.span);
break :blk self.builder.constType(ty);
},
.try_expr => |te| self.lowerTry(te.operand, node.span),
.catch_expr => |ce| self.lowerCatch(&ce, node.span),
.caller_location => self.lowerCallerLocation(node),