authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-29 18:40:28+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-29 21:44:08+02:00
log6f5a438946dce2b201acf5b7bbe42977bc990cc4
tree53e0290b28a6f8f6f070fb6cb08fb7ab9e7cc706
parente60db701d13a50798222bbef2d4560245f975671

AstGen: unstack block scope when creating opaque type

Closes #13697

2 files changed, 12 insertions(+), 0 deletions(-)

src/AstGen.zig+1
......@@ -5070,6 +5070,7 @@ fn containerDecl(
50705070 try astgen.extra.ensureUnusedCapacity(gpa, decls_slice.len);
50715071 astgen.extra.appendSliceAssumeCapacity(decls_slice);
50725072
5073 block_scope.unstack();
50735074 try gz.addNamespaceCaptures(&namespace);
50745075 return rvalue(gz, ri, indexToRef(decl_inst), node);
50755076 },
test/behavior/basic.zig+11
......@@ -1127,3 +1127,14 @@ test "pointer to zero sized global is mutable" {
11271127 };
11281128 try expect(@TypeOf(&S.thing) == *S.Thing);
11291129}
1130
1131test "returning an opaque type from a function" {
1132 const S = struct {
1133 fn foo(comptime a: u32) type {
1134 return opaque {
1135 const b = a;
1136 };
1137 }
1138 };
1139 try expect(S.foo(123).b == 123);
1140}