diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-03-15 15:53:50 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-15 20:12:22 -0400 |
| commit | fd43434149658ee482428714e05722e5a12fdecc (patch) | |
| tree | a2741731117e8a3cfc1f20232ef393f3434c064a /src | |
| parent | 1149e8bb088f48e29f3abc06196b1134f5e1c42f (diff) | |
| download | zig-fd43434149658ee482428714e05722e5a12fdecc.tar.gz zig-fd43434149658ee482428714e05722e5a12fdecc.zip | |
stage2: TypeInfo for func with generic return type should set null
Prior to these, the return type was non-null but the value was generic
poison which wasn't usable in user-space. This sets the value to null.
This also adds a behavior test for this.
Co-authored-by: InKryption <inkryption07@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 2ee64ca73d..fb2b187c60 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -10376,6 +10376,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai break :v try Value.Tag.decl_ref.create(sema.arena, new_decl); }; + const ret_ty_opt = if (info.return_type.tag() != .generic_poison) + try Value.Tag.opt_payload.create( + sema.arena, + try Value.Tag.ty.create(sema.arena, info.return_type), + ) + else + Value.@"null"; + const field_values = try sema.arena.create([6]Value); field_values.* = .{ // calling_convention: CallingConvention, @@ -10387,10 +10395,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai // is_var_args: bool, Value.makeBool(info.is_var_args), // return_type: ?type, - try Value.Tag.opt_payload.create( - sema.arena, - try Value.Tag.ty.create(sema.arena, info.return_type), - ), + ret_ty_opt, // args: []const Fn.Param, args_val, }; |
