mirror of
https://github.com/ziglang/zig.git
synced 2026-02-17 06:49:23 +00:00
AstGen: fix missing compile error for unreachable @TypeOf argument
This commit is contained in:
parent
7f5560689a
commit
22b20f20b6
@ -4228,8 +4228,8 @@ test "type of unreachable" {
|
||||
comptime {
|
||||
// The type of unreachable is noreturn.
|
||||
|
||||
// However this assertion will still fail because
|
||||
// evaluating unreachable at compile-time is a compile error.
|
||||
// However this assertion will still fail to compile because
|
||||
// unreachable expressions are compile errors.
|
||||
|
||||
assert(@TypeOf(unreachable) == noreturn);
|
||||
}
|
||||
|
||||
@ -6786,13 +6786,14 @@ fn typeOf(
|
||||
return gz.astgen.failNode(node, "expected at least 1 argument, found 0", .{});
|
||||
}
|
||||
if (params.len == 1) {
|
||||
const result = try gz.addUnNode(.typeof, try expr(gz, scope, .none, params[0]), node);
|
||||
const expr_result = try reachableExpr(gz, scope, .none, params[0], node);
|
||||
const result = try gz.addUnNode(.typeof, expr_result, node);
|
||||
return rvalue(gz, rl, result, node);
|
||||
}
|
||||
const arena = gz.astgen.arena;
|
||||
var items = try arena.alloc(Zir.Inst.Ref, params.len);
|
||||
for (params) |param, param_i| {
|
||||
items[param_i] = try expr(gz, scope, .none, param);
|
||||
items[param_i] = try reachableExpr(gz, scope, .none, param, node);
|
||||
}
|
||||
|
||||
const result = try gz.addExtendedMultiOp(.typeof_peer, node, items);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user