Commit 793db63746
Changed files (3)
test
src/Module.zig
@@ -1220,6 +1220,7 @@ pub const Union = struct {
};
const node = owner_decl.relativeToNodeIndex(u.node_offset);
const node_tags = tree.nodes.items(.tag);
+ var buf: [2]Ast.Node.Index = undefined;
switch (node_tags[node]) {
.container_decl,
.container_decl_trailing,
@@ -1231,6 +1232,15 @@ pub const Union = struct {
.container_decl_arg,
.container_decl_arg_trailing,
=> return queryFieldSrc(tree.*, query, file, tree.containerDeclArg(node)),
+ .tagged_union,
+ .tagged_union_trailing,
+ => return queryFieldSrc(tree.*, query, file, tree.taggedUnion(node)),
+ .tagged_union_two,
+ .tagged_union_two_trailing,
+ => return queryFieldSrc(tree.*, query, file, tree.taggedUnionTwo(&buf, node)),
+ .tagged_union_enum_tag,
+ .tagged_union_enum_tag_trailing,
+ => return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)),
else => unreachable,
}
}
src/Sema.zig
@@ -5695,6 +5695,7 @@ fn analyzeCall(
sema.inst_map.clearRetainingCapacity();
const decl = sema.mod.declPtr(block.src_decl);
child_block.src_decl = block.src_decl;
+ arg_i = 0;
try sema.analyzeInlineCallArg(
block,
&child_block,
@@ -12864,7 +12865,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
else
try Value.Tag.opt_payload.create(
params_anon_decl.arena(),
- try Value.Tag.ty.create(params_anon_decl.arena(), param_ty),
+ try Value.Tag.ty.create(params_anon_decl.arena(), try param_ty.copy(params_anon_decl.arena())),
);
const param_fields = try params_anon_decl.arena().create([3]Value);
@@ -26635,7 +26636,7 @@ fn getBuiltinType(
) CompileError!Type {
const ty_inst = try sema.getBuiltin(block, src, name);
const result_ty = try sema.analyzeAsType(block, src, ty_inst);
- try sema.queueFullTypeResolution(result_ty);
+ try sema.resolveTypeFully(block, src, result_ty); // Should not fail
return result_ty;
}
test/cases/fn_typeinfo_passed_to_comptime_fn.zig
@@ -0,0 +1,17 @@
+const std = @import("std");
+
+test {
+ try foo(@typeInfo(@TypeOf(someFn)));
+}
+
+fn someFn(arg: ?*c_int) f64 {
+ _ = arg;
+ return 8;
+}
+fn foo(comptime info: std.builtin.Type) !void {
+ try std.testing.expect(info.Fn.args[0].arg_type.? == ?*c_int);
+}
+
+// run
+// is_test=1
+//