| author | |
| committer | |
| log | 793db63746ca044927743ee94405dad2a3f02fb8 |
| tree | eba9986d8448894a37a262b0f4f790818c02690e |
| parent | 3818d63dd8b29596e4c3d2499463b7519258a611 |
Closes #122473 files changed, 30 insertions(+), 2 deletions(-)
src/Module.zig+10| ... | @@ -1220,6 +1220,7 @@ pub const Union = struct { | ... | @@ -1220,6 +1220,7 @@ pub const Union = struct { |
| 1220 | }; | 1220 | }; |
| 1221 | const node = owner_decl.relativeToNodeIndex(u.node_offset); | 1221 | const node = owner_decl.relativeToNodeIndex(u.node_offset); |
| 1222 | const node_tags = tree.nodes.items(.tag); | 1222 | const node_tags = tree.nodes.items(.tag); |
| 1223 | var buf: [2]Ast.Node.Index = undefined; | ||
| 1223 | switch (node_tags[node]) { | 1224 | switch (node_tags[node]) { |
| 1224 | .container_decl, | 1225 | .container_decl, |
| 1225 | .container_decl_trailing, | 1226 | .container_decl_trailing, |
| ... | @@ -1231,6 +1232,15 @@ pub const Union = struct { | ... | @@ -1231,6 +1232,15 @@ pub const Union = struct { |
| 1231 | .container_decl_arg, | 1232 | .container_decl_arg, |
| 1232 | .container_decl_arg_trailing, | 1233 | .container_decl_arg_trailing, |
| 1233 | => return queryFieldSrc(tree.*, query, file, tree.containerDeclArg(node)), | 1234 | => return queryFieldSrc(tree.*, query, file, tree.containerDeclArg(node)), |
| 1235 | .tagged_union, | ||
| 1236 | .tagged_union_trailing, | ||
| 1237 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnion(node)), | ||
| 1238 | .tagged_union_two, | ||
| 1239 | .tagged_union_two_trailing, | ||
| 1240 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnionTwo(&buf, node)), | ||
| 1241 | .tagged_union_enum_tag, | ||
| 1242 | .tagged_union_enum_tag_trailing, | ||
| 1243 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)), | ||
| 1234 | else => unreachable, | 1244 | else => unreachable, |
| 1235 | } | 1245 | } |
| 1236 | } | 1246 | } |
src/Sema.zig+3-2| ... | @@ -5695,6 +5695,7 @@ fn analyzeCall( | ... | @@ -5695,6 +5695,7 @@ fn analyzeCall( |
| 5695 | sema.inst_map.clearRetainingCapacity(); | 5695 | sema.inst_map.clearRetainingCapacity(); |
| 5696 | const decl = sema.mod.declPtr(block.src_decl); | 5696 | const decl = sema.mod.declPtr(block.src_decl); |
| 5697 | child_block.src_decl = block.src_decl; | 5697 | child_block.src_decl = block.src_decl; |
| 5698 | arg_i = 0; | ||
| 5698 | try sema.analyzeInlineCallArg( | 5699 | try sema.analyzeInlineCallArg( |
| 5699 | block, | 5700 | block, |
| 5700 | &child_block, | 5701 | &child_block, |
| ... | @@ -12864,7 +12865,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12864,7 +12865,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12864 | else | 12865 | else |
| 12865 | try Value.Tag.opt_payload.create( | 12866 | try Value.Tag.opt_payload.create( |
| 12866 | params_anon_decl.arena(), | 12867 | params_anon_decl.arena(), |
| 12867 | try Value.Tag.ty.create(params_anon_decl.arena(), param_ty), | 12868 | try Value.Tag.ty.create(params_anon_decl.arena(), try param_ty.copy(params_anon_decl.arena())), |
| 12868 | ); | 12869 | ); |
| 12869 | 12870 | ||
| 12870 | const param_fields = try params_anon_decl.arena().create([3]Value); | 12871 | const param_fields = try params_anon_decl.arena().create([3]Value); |
| ... | @@ -26635,7 +26636,7 @@ fn getBuiltinType( | ... | @@ -26635,7 +26636,7 @@ fn getBuiltinType( |
| 26635 | ) CompileError!Type { | 26636 | ) CompileError!Type { |
| 26636 | const ty_inst = try sema.getBuiltin(block, src, name); | 26637 | const ty_inst = try sema.getBuiltin(block, src, name); |
| 26637 | const result_ty = try sema.analyzeAsType(block, src, ty_inst); | 26638 | const result_ty = try sema.analyzeAsType(block, src, ty_inst); |
| 26638 | try sema.queueFullTypeResolution(result_ty); | 26639 | try sema.resolveTypeFully(block, src, result_ty); // Should not fail |
| 26639 | return result_ty; | 26640 | return result_ty; |
| 26640 | } | 26641 | } |
| 26641 | 26642 |
test/cases/fn_typeinfo_passed_to_comptime_fn.zig created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | test { | ||
| 4 | try foo(@typeInfo(@TypeOf(someFn))); | ||
| 5 | } | ||
| 6 | |||
| 7 | fn someFn(arg: ?*c_int) f64 { | ||
| 8 | _ = arg; | ||
| 9 | return 8; | ||
| 10 | } | ||
| 11 | fn foo(comptime info: std.builtin.Type) !void { | ||
| 12 | try std.testing.expect(info.Fn.args[0].arg_type.? == ?*c_int); | ||
| 13 | } | ||
| 14 | |||
| 15 | // run | ||
| 16 | // is_test=1 | ||
| 17 | // | ||