fix(0118): cast accepts compound type args; compound type literals are first-class Type values
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user