authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-11 11:33:09+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-11 23:49:33+03:00
log35c7e376b89f41d8260b70e770e03ef6af68849d
tree88734375267629dc08d0c33bb43fe399461a4d07
parent0333ff4476d0132a2397122dcab964de7fc0f2d3

stage2: improve anon name strategy for local variables


5 files changed, 118 insertions(+), 65 deletions(-)

lib/std/fmt.zig+46-18
......@@ -2190,18 +2190,22 @@ test "enum" {
21902190}
21912191
21922192test "non-exhaustive enum" {
2193 if (builtin.zig_backend == .stage1) {
2194 // stage1 fails to return fully qualified namespaces.
2195 return error.SkipZigTest;
2196 }
21932197 const Enum = enum(u16) {
21942198 One = 0x000f,
21952199 Two = 0xbeef,
21962200 _,
21972201 };
2198 try expectFmt("enum: Enum.One\n", "enum: {}\n", .{Enum.One});
2199 try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{Enum.Two});
2200 try expectFmt("enum: Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)});
2201 try expectFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One});
2202 try expectFmt("enum: Enum.Two\n", "enum: {x}\n", .{Enum.Two});
2203 try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two});
2204 try expectFmt("enum: Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)});
2202 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {}\n", .{Enum.One});
2203 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {}\n", .{Enum.Two});
2204 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)});
2205 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {x}\n", .{Enum.One});
2206 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {x}\n", .{Enum.Two});
2207 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {X}\n", .{Enum.Two});
2208 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)});
22052209}
22062210
22072211test "float.scientific" {
......@@ -2357,6 +2361,10 @@ test "custom" {
23572361}
23582362
23592363test "struct" {
2364 if (builtin.zig_backend == .stage1) {
2365 // stage1 fails to return fully qualified namespaces.
2366 return error.SkipZigTest;
2367 }
23602368 const S = struct {
23612369 a: u32,
23622370 b: anyerror,
......@@ -2367,7 +2375,7 @@ test "struct" {
23672375 .b = error.Unused,
23682376 };
23692377
2370 try expectFmt("S{ .a = 456, .b = error.Unused }", "{}", .{inst});
2378 try expectFmt("fmt.test.struct.S{ .a = 456, .b = error.Unused }", "{}", .{inst});
23712379 // Tuples
23722380 try expectFmt("{ }", "{}", .{.{}});
23732381 try expectFmt("{ -1 }", "{}", .{.{-1}});
......@@ -2375,6 +2383,10 @@ test "struct" {
23752383}
23762384
23772385test "union" {
2386 if (builtin.zig_backend == .stage1) {
2387 // stage1 fails to return fully qualified namespaces.
2388 return error.SkipZigTest;
2389 }
23782390 const TU = union(enum) {
23792391 float: f32,
23802392 int: u32,
......@@ -2394,17 +2406,21 @@ test "union" {
23942406 const uu_inst = UU{ .int = 456 };
23952407 const eu_inst = EU{ .float = 321.123 };
23962408
2397 try expectFmt("TU{ .int = 123 }", "{}", .{tu_inst});
2409 try expectFmt("fmt.test.union.TU{ .int = 123 }", "{}", .{tu_inst});
23982410
23992411 var buf: [100]u8 = undefined;
24002412 const uu_result = try bufPrint(buf[0..], "{}", .{uu_inst});
2401 try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@"));
2413 try std.testing.expect(mem.eql(u8, uu_result[0..18], "fmt.test.union.UU@"));
24022414
24032415 const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst});
2404 try std.testing.expect(mem.eql(u8, eu_result[0..3], "EU@"));
2416 try std.testing.expect(mem.eql(u8, eu_result[0..18], "fmt.test.union.EU@"));
24052417}
24062418
24072419test "enum" {
2420 if (builtin.zig_backend == .stage1) {
2421 // stage1 fails to return fully qualified namespaces.
2422 return error.SkipZigTest;
2423 }
24082424 const E = enum {
24092425 One,
24102426 Two,
......@@ -2413,10 +2429,14 @@ test "enum" {
24132429
24142430 const inst = E.Two;
24152431
2416 try expectFmt("E.Two", "{}", .{inst});
2432 try expectFmt("fmt.test.enum.E.Two", "{}", .{inst});
24172433}
24182434
24192435test "struct.self-referential" {
2436 if (builtin.zig_backend == .stage1) {
2437 // stage1 fails to return fully qualified namespaces.
2438 return error.SkipZigTest;
2439 }
24202440 const S = struct {
24212441 const SelfType = @This();
24222442 a: ?*SelfType,
......@@ -2427,10 +2447,14 @@ test "struct.self-referential" {
24272447 };
24282448 inst.a = &inst;
24292449
2430 try expectFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", .{inst});
2450 try expectFmt("fmt.test.struct.self-referential.S{ .a = fmt.test.struct.self-referential.S{ .a = fmt.test.struct.self-referential.S{ .a = fmt.test.struct.self-referential.S{ ... } } } }", "{}", .{inst});
24312451}
24322452
24332453test "struct.zero-size" {
2454 if (builtin.zig_backend == .stage1) {
2455 // stage1 fails to return fully qualified namespaces.
2456 return error.SkipZigTest;
2457 }
24342458 const A = struct {
24352459 fn foo() void {}
24362460 };
......@@ -2442,7 +2466,7 @@ test "struct.zero-size" {
24422466 const a = A{};
24432467 const b = B{ .a = a, .c = 0 };
24442468
2445 try expectFmt("B{ .a = A{ }, .c = 0 }", "{}", .{b});
2469 try expectFmt("fmt.test.struct.zero-size.B{ .a = fmt.test.struct.zero-size.A{ }, .c = 0 }", "{}", .{b});
24462470}
24472471
24482472test "bytes.hex" {
......@@ -2508,6 +2532,10 @@ test "formatFloatValue with comptime_float" {
25082532}
25092533
25102534test "formatType max_depth" {
2535 if (builtin.zig_backend == .stage1) {
2536 // stage1 fails to return fully qualified namespaces.
2537 return error.SkipZigTest;
2538 }
25112539 const Vec2 = struct {
25122540 const SelfType = @This();
25132541 x: f32,
......@@ -2558,19 +2586,19 @@ test "formatType max_depth" {
25582586 var buf: [1000]u8 = undefined;
25592587 var fbs = std.io.fixedBufferStream(&buf);
25602588 try formatType(inst, "", FormatOptions{}, fbs.writer(), 0);
2561 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ ... }"));
2589 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ ... }"));
25622590
25632591 fbs.reset();
25642592 try formatType(inst, "", FormatOptions{}, fbs.writer(), 1);
2565 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }"));
2593 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ ... }, .tu = fmt.test.formatType max_depth.TU{ ... }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }"));
25662594
25672595 fbs.reset();
25682596 try formatType(inst, "", FormatOptions{}, fbs.writer(), 2);
2569 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }"));
2597 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ ... }, .tu = fmt.test.formatType max_depth.TU{ ... }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }, .tu = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ ... } }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }"));
25702598
25712599 fbs.reset();
25722600 try formatType(inst, "", FormatOptions{}, fbs.writer(), 3);
2573 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ .a = S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ .ptr = TU{ ... } } }, .e = E.Two, .vec = (10.200,2.220) }"));
2601 try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ ... }, .tu = fmt.test.formatType max_depth.TU{ ... }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }, .tu = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ ... } }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }, .tu = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ ... } } }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }"));
25742602}
25752603
25762604test "positional" {
src/AstGen.zig+7
......@@ -2753,7 +2753,10 @@ fn varDecl(
27532753 const result_loc: ResultLoc = if (type_node != 0) .{
27542754 .ty = try typeExpr(gz, scope, type_node),
27552755 } else .none;
2756 const prev_anon_name_strategy = gz.anon_name_strategy;
2757 gz.anon_name_strategy = .dbg_var;
27562758 const init_inst = try reachableExpr(gz, scope, result_loc, var_decl.ast.init_node, node);
2759 gz.anon_name_strategy = prev_anon_name_strategy;
27572760
27582761 try gz.addDbgVar(.dbg_var_val, ident_name, init_inst);
27592762
......@@ -2777,6 +2780,7 @@ fn varDecl(
27772780 var init_scope = gz.makeSubBlock(scope);
27782781 // we may add more instructions to gz before stacking init_scope
27792782 init_scope.instructions_top = GenZir.unstacked_top;
2783 init_scope.anon_name_strategy = .dbg_var;
27802784 defer init_scope.unstack();
27812785
27822786 var resolve_inferred_alloc: Zir.Inst.Ref = .none;
......@@ -2956,7 +2960,10 @@ fn varDecl(
29562960 resolve_inferred_alloc = alloc;
29572961 break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc } };
29582962 };
2963 const prev_anon_name_strategy = gz.anon_name_strategy;
2964 gz.anon_name_strategy = .dbg_var;
29592965 _ = try reachableExprComptime(gz, scope, var_data.result_loc, var_decl.ast.init_node, node, is_comptime);
2966 gz.anon_name_strategy = prev_anon_name_strategy;
29602967 if (resolve_inferred_alloc != .none) {
29612968 _ = try gz.addUnNode(.resolve_inferred_alloc, resolve_inferred_alloc, node);
29622969 }
src/Sema.zig+38-11
......@@ -914,9 +914,9 @@ fn analyzeBodyInner(
914914 // zig fmt: off
915915 .variable => try sema.zirVarExtended( block, extended),
916916 .struct_decl => try sema.zirStructDecl( block, extended, inst),
917 .enum_decl => try sema.zirEnumDecl( block, extended),
917 .enum_decl => try sema.zirEnumDecl( block, extended, inst),
918918 .union_decl => try sema.zirUnionDecl( block, extended, inst),
919 .opaque_decl => try sema.zirOpaqueDecl( block, extended),
919 .opaque_decl => try sema.zirOpaqueDecl( block, extended, inst),
920920 .this => try sema.zirThis( block, extended),
921921 .ret_addr => try sema.zirRetAddr( block, extended),
922922 .builtin_src => try sema.zirBuiltinSrc( block, extended),
......@@ -2101,7 +2101,7 @@ fn zirStructDecl(
21012101 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
21022102 .ty = Type.type,
21032103 .val = struct_val,
2104 }, small.name_strategy, "struct");
2104 }, small.name_strategy, "struct", inst);
21052105 const new_decl = mod.declPtr(new_decl_index);
21062106 new_decl.owns_tv = true;
21072107 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -2133,6 +2133,7 @@ fn createAnonymousDeclTypeNamed(
21332133 typed_value: TypedValue,
21342134 name_strategy: Zir.Inst.NameStrategy,
21352135 anon_prefix: []const u8,
2136 inst: ?Zir.Inst.Index,
21362137) !Decl.Index {
21372138 const mod = sema.mod;
21382139 const namespace = block.namespace;
......@@ -2152,11 +2153,13 @@ fn createAnonymousDeclTypeNamed(
21522153 const name = try std.fmt.allocPrintZ(sema.gpa, "{s}__{s}_{d}", .{
21532154 src_decl.name, anon_prefix, @enumToInt(new_decl_index),
21542155 });
2156 errdefer sema.gpa.free(name);
21552157 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, typed_value, name);
21562158 return new_decl_index;
21572159 },
21582160 .parent => {
21592161 const name = try sema.gpa.dupeZ(u8, mem.sliceTo(sema.mod.declPtr(block.src_decl).name, 0));
2162 errdefer sema.gpa.free(name);
21602163 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, typed_value, name);
21612164 return new_decl_index;
21622165 },
......@@ -2188,9 +2191,31 @@ fn createAnonymousDeclTypeNamed(
21882191
21892192 try buf.appendSlice(")");
21902193 const name = try buf.toOwnedSliceSentinel(0);
2194 errdefer sema.gpa.free(name);
21912195 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, typed_value, name);
21922196 return new_decl_index;
21932197 },
2198 .dbg_var => {
2199 const ref = Zir.indexToRef(inst.?);
2200 const zir_tags = sema.code.instructions.items(.tag);
2201 const zir_data = sema.code.instructions.items(.data);
2202 var i = inst.?;
2203 while (i < zir_tags.len) : (i += 1) switch (zir_tags[i]) {
2204 .dbg_var_ptr, .dbg_var_val => {
2205 if (zir_data[i].str_op.operand != ref) continue;
2206
2207 const name = try std.fmt.allocPrintZ(sema.gpa, "{s}.{s}", .{
2208 src_decl.name, zir_data[i].str_op.getStr(sema.code),
2209 });
2210 errdefer sema.gpa.free(name);
2211
2212 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, typed_value, name);
2213 return new_decl_index;
2214 },
2215 else => {},
2216 };
2217 return sema.createAnonymousDeclTypeNamed(block, typed_value, .anon, anon_prefix, null);
2218 },
21942219 }
21952220}
21962221
......@@ -2198,6 +2223,7 @@ fn zirEnumDecl(
21982223 sema: *Sema,
21992224 block: *Block,
22002225 extended: Zir.Inst.Extended.InstData,
2226 inst: Zir.Inst.Index,
22012227) CompileError!Air.Inst.Ref {
22022228 const tracy = trace(@src());
22032229 defer tracy.end();
......@@ -2252,7 +2278,7 @@ fn zirEnumDecl(
22522278 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
22532279 .ty = Type.type,
22542280 .val = enum_val,
2255 }, small.name_strategy, "enum");
2281 }, small.name_strategy, "enum", inst);
22562282 const new_decl = mod.declPtr(new_decl_index);
22572283 new_decl.owns_tv = true;
22582284 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -2472,7 +2498,7 @@ fn zirUnionDecl(
24722498 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
24732499 .ty = Type.type,
24742500 .val = union_val,
2475 }, small.name_strategy, "union");
2501 }, small.name_strategy, "union", inst);
24762502 const new_decl = mod.declPtr(new_decl_index);
24772503 new_decl.owns_tv = true;
24782504 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -2504,6 +2530,7 @@ fn zirOpaqueDecl(
25042530 sema: *Sema,
25052531 block: *Block,
25062532 extended: Zir.Inst.Extended.InstData,
2533 inst: Zir.Inst.Index,
25072534) CompileError!Air.Inst.Ref {
25082535 const tracy = trace(@src());
25092536 defer tracy.end();
......@@ -2540,7 +2567,7 @@ fn zirOpaqueDecl(
25402567 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
25412568 .ty = Type.type,
25422569 .val = opaque_val,
2543 }, small.name_strategy, "opaque");
2570 }, small.name_strategy, "opaque", inst);
25442571 const new_decl = mod.declPtr(new_decl_index);
25452572 new_decl.owns_tv = true;
25462573 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -2589,7 +2616,7 @@ fn zirErrorSetDecl(
25892616 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
25902617 .ty = Type.type,
25912618 .val = error_set_val,
2592 }, name_strategy, "error");
2619 }, name_strategy, "error", inst);
25932620 const new_decl = mod.declPtr(new_decl_index);
25942621 new_decl.owns_tv = true;
25952622 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -14632,7 +14659,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1463214659 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
1463314660 .ty = Type.type,
1463414661 .val = enum_val,
14635 }, .anon, "enum");
14662 }, .anon, "enum", null);
1463614663 const new_decl = mod.declPtr(new_decl_index);
1463714664 new_decl.owns_tv = true;
1463814665 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -14722,7 +14749,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1472214749 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
1472314750 .ty = Type.type,
1472414751 .val = opaque_val,
14725 }, .anon, "opaque");
14752 }, .anon, "opaque", null);
1472614753 const new_decl = mod.declPtr(new_decl_index);
1472714754 new_decl.owns_tv = true;
1472814755 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -14773,7 +14800,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1477314800 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
1477414801 .ty = Type.type,
1477514802 .val = new_union_val,
14776 }, .anon, "union");
14803 }, .anon, "union", null);
1477714804 const new_decl = mod.declPtr(new_decl_index);
1477814805 new_decl.owns_tv = true;
1477914806 errdefer mod.abortAnonDecl(new_decl_index);
......@@ -14941,7 +14968,7 @@ fn reifyStruct(
1494114968 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{
1494214969 .ty = Type.type,
1494314970 .val = new_struct_val,
14944 }, .anon, "struct");
14971 }, .anon, "struct", null);
1494514972 const new_decl = mod.declPtr(new_decl_index);
1494614973 new_decl.owns_tv = true;
1494714974 errdefer mod.abortAnonDecl(new_decl_index);
src/Zir.zig+2
......@@ -3156,6 +3156,8 @@ pub const Inst = struct {
31563156 /// Create an anonymous name for this declaration.
31573157 /// Like this: "ParentDeclName_struct_69"
31583158 anon,
3159 /// Use the name specified in the next `dbg_var_{val,ptr}` instruction.
3160 dbg_var,
31593161 };
31603162
31613163 /// Trailing:
test/behavior/typename.zig+25-36
......@@ -137,43 +137,8 @@ const A_Enum = enum {
137137
138138fn regular() void {}
139139
140test "fn body decl" {
141 if (builtin.zig_backend == .stage1) {
142 // stage1 fails to return fully qualified namespaces.
143 return error.SkipZigTest;
144 }
145
146 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
147 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
148 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
149 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
150
151 try B.doTest();
152}
153
154140const B = struct {
155 fn doTest() !void {
156 const B_Struct = struct {};
157 const B_Union = union {
158 unused: u8,
159 };
160 const B_Enum = enum {
161 unused,
162 };
163
164 try expectEqualStringsIgnoreDigits(
165 "behavior.typename.B.doTest__struct_0",
166 @typeName(B_Struct),
167 );
168 try expectEqualStringsIgnoreDigits(
169 "behavior.typename.B.doTest__union_0",
170 @typeName(B_Union),
171 );
172 try expectEqualStringsIgnoreDigits(
173 "behavior.typename.B.doTest__enum_0",
174 @typeName(B_Enum),
175 );
176 }
141 fn doTest() !void {}
177142};
178143
179144test "fn param" {
......@@ -246,3 +211,27 @@ pub fn expectEqualStringsIgnoreDigits(expected: []const u8, actual: []const u8)
246211 }
247212 return expectEqualStrings(expected, actual_buf[0..actual_i]);
248213}
214
215test "local variable" {
216 if (builtin.zig_backend == .stage1) {
217 // stage1 fails to return fully qualified namespaces.
218 return error.SkipZigTest;
219 }
220
221 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
222 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
223 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
224 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
225
226 const Foo = struct { a: u32 };
227 const Bar = union { a: u32 };
228 const Baz = enum { a, b };
229 const Qux = enum { a, b };
230 const Quux = enum { a, b };
231
232 try expectEqualStrings("behavior.typename.test.local variable.Foo", @typeName(Foo));
233 try expectEqualStrings("behavior.typename.test.local variable.Bar", @typeName(Bar));
234 try expectEqualStrings("behavior.typename.test.local variable.Baz", @typeName(Baz));
235 try expectEqualStrings("behavior.typename.test.local variable.Qux", @typeName(Qux));
236 try expectEqualStrings("behavior.typename.test.local variable.Quux", @typeName(Quux));
237}