authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 18:58:41-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 20:21:57-04:00
logc6295fe9abf5508d522ab4000b577a6f30a98a88
treede5ff247f235fbf8f9cfe6f8ad2267c897c4d022
parent6db589fff5be05e3e782a34443a1133ebc6ef17d

remove zigrt

adds test case for #394 partially reverts a32b5929ccf8cbf79396d8924097a1a911985dac

13 files changed, 109 insertions(+), 122 deletions(-)

CMakeLists.txt+1-1
......@@ -585,8 +585,8 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivmod.zig" DESTINAT
585585install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivmoddi4.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
586586install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivmodti4.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
587587install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/umodti3.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
588install(FILES "${CMAKE_SOURCE_DIR}/std/special/panic.zig" DESTINATION "${ZIG_STD_DEST}/special")
588589install(FILES "${CMAKE_SOURCE_DIR}/std/special/test_runner.zig" DESTINATION "${ZIG_STD_DEST}/special")
589install(FILES "${CMAKE_SOURCE_DIR}/std/special/zigrt.zig" DESTINATION "${ZIG_STD_DEST}/special")
590590
591591if (ZIG_TEST_COVERAGE)
592592 add_custom_target(coverage
src/all_types.hpp+2-4
......@@ -1472,7 +1472,7 @@ struct CodeGen {
14721472 bool is_native_target;
14731473 PackageTableEntry *root_package;
14741474 PackageTableEntry *std_package;
1475 PackageTableEntry *zigrt_package;
1475 PackageTableEntry *panic_package;
14761476 PackageTableEntry *test_runner_package;
14771477 PackageTableEntry *compile_var_package;
14781478 ImportTableEntry *compile_var_import;
......@@ -1484,7 +1484,6 @@ struct CodeGen {
14841484 Buf *mios_version_min;
14851485 bool linker_rdynamic;
14861486 const char *linker_script;
1487 bool omit_zigrt;
14881487
14891488 // The function definitions this module includes. There must be a corresponding
14901489 // fn_protos entry.
......@@ -1498,8 +1497,7 @@ struct CodeGen {
14981497 OutType out_type;
14991498 FnTableEntry *cur_fn;
15001499 FnTableEntry *main_fn;
1501 FnTableEntry *user_panic_fn;
1502 FnTableEntry *extern_panic_fn;
1500 FnTableEntry *panic_fn;
15031501 LLVMValueRef cur_ret_ptr;
15041502 LLVMValueRef cur_fn_val;
15051503 bool c_want_stdint;
src/analyze.cpp+7-48
......@@ -2072,11 +2072,10 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
20722072 if (fn_def_node)
20732073 g->fn_defs.append(fn_table_entry);
20742074
2075 if (g->have_pub_main && scope_is_root_decls(tld_fn->base.parent_scope) &&
2076 ((!g->is_test_build && import == g->root_import) ||
2077 (g->is_test_build && import == g->test_runner_import)))
2075 if (scope_is_root_decls(tld_fn->base.parent_scope) &&
2076 (import == g->root_import || import->package == g->panic_package))
20782077 {
2079 if (buf_eql_str(&fn_table_entry->symbol_name, "main")) {
2078 if (g->have_pub_main && buf_eql_str(&fn_table_entry->symbol_name, "main")) {
20802079 g->main_fn = fn_table_entry;
20812080
20822081 if (tld_fn->base.visib_mod != VisibModExport) {
......@@ -2088,13 +2087,12 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
20882087 buf_ptr(&actual_return_type->name)));
20892088 }
20902089 }
2091 } else if (buf_eql_str(&fn_table_entry->symbol_name, "panic")) {
2090 } else if ((import->package == g->panic_package || g->have_pub_panic) &&
2091 buf_eql_str(&fn_table_entry->symbol_name, "panic"))
2092 {
2093 g->panic_fn = fn_table_entry;
20922094 typecheck_panic_fn(g, fn_table_entry);
20932095 }
2094 } else if (import->package == g->zigrt_package && scope_is_root_decls(tld_fn->base.parent_scope)) {
2095 if (buf_eql_str(&fn_table_entry->symbol_name, "__zig_panic")) {
2096 g->extern_panic_fn = fn_table_entry;
2097 }
20982096 }
20992097 }
21002098 } else if (source_node->type == NodeTypeTestDecl) {
......@@ -2272,14 +2270,6 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
22722270 tld_fn->extern_lib_name = node->data.fn_proto.lib_name;
22732271 add_top_level_decl(g, decls_scope, &tld_fn->base);
22742272
2275 ImportTableEntry *import = get_scope_import(&decls_scope->base);
2276 if (import == g->root_import && scope_is_root_decls(&decls_scope->base) &&
2277 buf_eql_str(fn_name, "panic"))
2278 {
2279 update_compile_var(g, buf_create_from_str("__zig_panic_implementation_provided"),
2280 create_const_bool(g, true));
2281 }
2282
22832273 break;
22842274 }
22852275 case NodeTypeUse:
......@@ -4606,37 +4596,6 @@ ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {
46064596 return nullptr;
46074597}
46084598
4609FnTableEntry *get_extern_panic_fn(CodeGen *g) {
4610 if (g->extern_panic_fn)
4611 return g->extern_panic_fn;
4612
4613 FnTypeId fn_type_id = {0};
4614 fn_type_id.cc = CallingConventionCold;
4615 fn_type_id.param_count = 2;
4616 fn_type_id.param_info = allocate<FnTypeParamInfo>(2);
4617 fn_type_id.next_param_index = 0;
4618 fn_type_id.param_info[0].type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
4619 fn_type_id.param_info[1].type = g->builtin_types.entry_usize;
4620 fn_type_id.return_type = g->builtin_types.entry_unreachable;
4621
4622 TypeTableEntry *fn_type = get_fn_type(g, &fn_type_id);
4623 assert(!type_is_invalid(fn_type));
4624
4625 FnTableEntry *fn_entry = create_fn_raw(FnInlineAuto, GlobalLinkageIdStrong);
4626 buf_init_from_str(&fn_entry->symbol_name, "__zig_panic");
4627
4628 TldFn *tld_fn = allocate<TldFn>(1);
4629 init_tld(&tld_fn->base, TldIdFn, &fn_entry->symbol_name, VisibModPrivate, nullptr, nullptr);
4630 tld_fn->fn_entry = fn_entry;
4631
4632 g->external_prototypes.put_unique(tld_fn->base.name, &tld_fn->base);
4633
4634 fn_entry->type_entry = fn_type;
4635
4636 g->extern_panic_fn = fn_entry;
4637 return g->extern_panic_fn;
4638}
4639
46404599static const TypeTableEntryId all_type_ids[] = {
46414600 TypeTableEntryIdMetaType,
46424601 TypeTableEntryIdVoid,
src/analyze.hpp-1
......@@ -157,7 +157,6 @@ ConstExprValue *create_const_vals(size_t count);
157157
158158TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
159159ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value);
160FnTableEntry *get_extern_panic_fn(CodeGen *g);
161160TypeTableEntry *create_enum_tag_type(CodeGen *g, TypeTableEntry *enum_type, TypeTableEntry *int_type);
162161void expand_undef_array(CodeGen *g, ConstExprValue *const_val);
163162void update_compile_var(CodeGen *g, Buf *name, ConstExprValue *value);
src/codegen.cpp+49-45
......@@ -157,10 +157,6 @@ void codegen_set_llvm_argv(CodeGen *g, const char **args, size_t len) {
157157 g->llvm_argv_len = len;
158158}
159159
160void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt) {
161 g->omit_zigrt = omit_zigrt;
162}
163
164160void codegen_set_test_filter(CodeGen *g, Buf *filter) {
165161 g->test_filter = filter;
166162}
......@@ -751,26 +747,12 @@ static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) {
751747 return val->global_refs->llvm_global;
752748}
753749
754static void gen_panic_raw(CodeGen *g, LLVMValueRef msg_ptr, LLVMValueRef msg_len) {
755 FnTableEntry *panic_fn = get_extern_panic_fn(g);
756 LLVMValueRef fn_val = fn_llvm_value(g, panic_fn);
757 LLVMValueRef args[] = { msg_ptr, msg_len };
758 LLVMCallConv llvm_cc = get_llvm_cc(g, panic_fn->type_entry->data.fn.fn_type_id.cc);
759 ZigLLVMBuildCall(g->builder, fn_val, args, 2, llvm_cc, false, "");
760 LLVMBuildUnreachable(g->builder);
761}
762
763750static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) {
764 TypeTableEntry *ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
765 TypeTableEntry *str_type = get_slice_type(g, ptr_type);
766 size_t ptr_index = str_type->data.structure.fields[slice_ptr_index].gen_index;
767 size_t len_index = str_type->data.structure.fields[slice_len_index].gen_index;
768 LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)ptr_index, "");
769 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)len_index, "");
770
771 LLVMValueRef msg_ptr = gen_load_untyped(g, ptr_ptr, 0, false, "");
772 LLVMValueRef msg_len = gen_load_untyped(g, len_ptr, 0, false, "");
773 gen_panic_raw(g, msg_ptr, msg_len);
751 assert(g->panic_fn != nullptr);
752 LLVMValueRef fn_val = fn_llvm_value(g, g->panic_fn);
753 LLVMCallConv llvm_cc = get_llvm_cc(g, g->panic_fn->type_entry->data.fn.fn_type_id.cc);
754 ZigLLVMBuildCall(g->builder, fn_val, &msg_arg, 1, llvm_cc, false, "");
755 LLVMBuildUnreachable(g->builder);
774756}
775757
776758static void gen_debug_safety_crash(CodeGen *g, PanicMsgId msg_id) {
......@@ -818,26 +800,40 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
818800 }
819801 uint32_t u8_align_bytes = get_abi_alignment(g, g->builtin_types.entry_u8);
820802 LLVMValueRef init_value = LLVMConstArray(LLVMInt8Type(), err_buf_vals, err_buf_len);
821 Buf *global_name = get_mangled_name(g, buf_create_from_str("__zig_panic_buf"), false);
822 LLVMValueRef global_value = LLVMAddGlobal(g->module, LLVMTypeOf(init_value), buf_ptr(global_name));
823 LLVMSetInitializer(global_value, init_value);
824 LLVMSetLinkage(global_value, LLVMInternalLinkage);
825 LLVMSetGlobalConstant(global_value, false);
826 LLVMSetUnnamedAddr(global_value, true);
827 LLVMSetAlignment(global_value, u8_align_bytes);
803 LLVMValueRef global_array = LLVMAddGlobal(g->module, LLVMTypeOf(init_value), "");
804 LLVMSetInitializer(global_array, init_value);
805 LLVMSetLinkage(global_array, LLVMInternalLinkage);
806 LLVMSetGlobalConstant(global_array, false);
807 LLVMSetUnnamedAddr(global_array, true);
808 LLVMSetAlignment(global_array, u8_align_bytes);
828809
829810 TypeTableEntry *usize = g->builtin_types.entry_usize;
830811 LLVMValueRef full_buf_ptr_indices[] = {
831812 LLVMConstNull(usize->type_ref),
832813 LLVMConstNull(usize->type_ref),
833814 };
834 LLVMValueRef full_buf_ptr = LLVMConstInBoundsGEP(global_value, full_buf_ptr_indices, 2);
815 LLVMValueRef full_buf_ptr = LLVMConstInBoundsGEP(global_array, full_buf_ptr_indices, 2);
816
817
818 TypeTableEntry *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
819 TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);
820 LLVMValueRef global_slice_fields[] = {
821 full_buf_ptr,
822 LLVMConstNull(usize->type_ref),
823 };
824 LLVMValueRef slice_init_value = LLVMConstNamedStruct(str_type->type_ref, global_slice_fields, 2);
825 LLVMValueRef global_slice = LLVMAddGlobal(g->module, LLVMTypeOf(slice_init_value), "");
826 LLVMSetInitializer(global_slice, slice_init_value);
827 LLVMSetLinkage(global_slice, LLVMInternalLinkage);
828 LLVMSetGlobalConstant(global_slice, false);
829 LLVMSetUnnamedAddr(global_slice, true);
830 LLVMSetAlignment(global_slice, get_abi_alignment(g, str_type));
835831
836832 LLVMValueRef offset_ptr_indices[] = {
837833 LLVMConstNull(usize->type_ref),
838834 LLVMConstInt(usize->type_ref, unwrap_err_msg_text_len, false),
839835 };
840 LLVMValueRef offset_buf_ptr = LLVMConstInBoundsGEP(global_value, offset_ptr_indices, 2);
836 LLVMValueRef offset_buf_ptr = LLVMConstInBoundsGEP(global_array, offset_ptr_indices, 2);
841837
842838 Buf *fn_name = get_mangled_name(g, buf_create_from_str("__zig_fail_unwrap"), false);
843839 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), &g->err_tag_type->type_ref, 1, false);
......@@ -888,7 +884,10 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
888884 LLVMValueRef const_prefix_len = LLVMConstInt(LLVMTypeOf(err_name_len), strlen(unwrap_err_msg_text), false);
889885 LLVMValueRef full_buf_len = LLVMBuildNUWAdd(g->builder, const_prefix_len, err_name_len, "");
890886
891 gen_panic_raw(g, full_buf_ptr, full_buf_len);
887 LLVMValueRef global_slice_len_field_ptr = LLVMBuildStructGEP(g->builder, global_slice, slice_len_index, "");
888 gen_store(g, full_buf_len, global_slice_len_field_ptr, u8_ptr_type);
889
890 gen_panic(g, global_slice);
892891
893892 LLVMPositionBuilderAtEnd(g->builder, prev_block);
894893 LLVMSetCurrentDebugLocation(g->builder, prev_debug_location);
......@@ -3744,8 +3743,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
37443743 fields[type_struct_field->gen_index] = gen_const_val(g, &const_val->data.x_struct.fields[i]);
37453744 }
37463745 }
3747 return LLVMConstStruct(fields, type_entry->data.structure.gen_field_count,
3748 type_entry->data.structure.layout == ContainerLayoutPacked);
3746 return LLVMConstNamedStruct(type_entry->type_ref, fields, type_entry->data.structure.gen_field_count);
37493747 }
37503748 case TypeTableEntryIdUnion:
37513749 {
......@@ -4103,7 +4101,7 @@ static void validate_inline_fns(CodeGen *g) {
41034101}
41044102
41054103static void do_code_gen(CodeGen *g) {
4106 if (g->verbose || g->verbose_ir) {
4104 if (g->verbose) {
41074105 fprintf(stderr, "\nCode Generation:\n");
41084106 fprintf(stderr, "------------------\n");
41094107 }
......@@ -4918,8 +4916,6 @@ static void define_builtin_compile_vars(CodeGen *g) {
49184916 buf_appendf(contents, "pub const mode = %s;\n", build_mode_to_str(g->build_mode));
49194917 buf_appendf(contents, "pub const link_libc = %s;\n", bool_to_str(g->libc_link_lib != nullptr));
49204918
4921 buf_appendf(contents, "pub const __zig_panic_implementation_provided = %s; // overwritten later\n",
4922 bool_to_str(false));
49234919 buf_appendf(contents, "pub const __zig_test_fn_slice = {}; // overwritten later\n");
49244920
49254921 ensure_cache_dir(g);
......@@ -5105,10 +5101,8 @@ static PackageTableEntry *create_test_runner_pkg(CodeGen *g) {
51055101 return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "test_runner.zig");
51065102}
51075103
5108static PackageTableEntry *create_zigrt_pkg(CodeGen *g) {
5109 PackageTableEntry *package = codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "zigrt.zig");
5110 package->package_table.put(buf_create_from_str("@root"), g->root_package);
5111 return package;
5104static PackageTableEntry *create_panic_pkg(CodeGen *g) {
5105 return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "panic.zig");
51125106}
51135107
51145108static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
......@@ -5190,9 +5184,19 @@ static void gen_root_source(CodeGen *g) {
51905184 {
51915185 g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap.zig");
51925186 }
5193 if (!g->omit_zigrt) {
5194 g->zigrt_package = create_zigrt_pkg(g);
5195 add_special_code(g, g->zigrt_package, "zigrt.zig");
5187 ImportTableEntry *import_with_panic;
5188 if (g->have_pub_panic) {
5189 import_with_panic = g->root_import;
5190 } else {
5191 g->panic_package = create_panic_pkg(g);
5192 import_with_panic = add_special_code(g, g->panic_package, "panic.zig");
5193 }
5194 // Zig has lazy top level definitions. Here we semantically analyze the panic function.
5195 {
5196 scan_import(g, import_with_panic);
5197 Tld *panic_tld = find_decl(g, &import_with_panic->decls_scope->base, buf_create_from_str("panic"));
5198 assert(panic_tld != nullptr);
5199 resolve_top_level_decl(g, panic_tld, false, nullptr);
51965200 }
51975201
51985202 if (g->verbose) {
src/codegen.hpp-1
......@@ -41,7 +41,6 @@ void codegen_set_rdynamic(CodeGen *g, bool rdynamic);
4141void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min);
4242void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min);
4343void codegen_set_linker_script(CodeGen *g, const char *linker_script);
44void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt);
4544void codegen_set_test_filter(CodeGen *g, Buf *filter);
4645void codegen_set_test_name_prefix(CodeGen *g, Buf *prefix);
4746void codegen_set_lib_version(CodeGen *g, size_t major, size_t minor, size_t patch);
src/link.cpp-1
......@@ -35,7 +35,6 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
3535 ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;
3636 CodeGen *child_gen = codegen_create(full_path, child_target, OutTypeObj, parent_gen->build_mode);
3737
38 codegen_set_omit_zigrt(child_gen, true);
3938 child_gen->want_h_file = false;
4039 child_gen->verbose_link = parent_gen->verbose_link;
4140
std/special/builtin.zig+16-3
......@@ -1,11 +1,21 @@
11// These functions are provided when not linking against libc because LLVM
22// sometimes generates code that calls them.
33
4// Note that these functions do not return `dest`, like the libc API.
5// The semantics of these functions is dictated by the corresponding
6// LLVM intrinsics, not by the libc API.
74const builtin = @import("builtin");
85
6// Avoid dragging in the debug safety mechanisms into this .o file,
7// unless we're trying to test this file.
8pub coldcc fn panic(msg: []const u8) -> noreturn {
9 if (builtin.is_test) {
10 @import("std").debug.panic("{}", msg);
11 } else {
12 unreachable;
13 }
14}
15
16// Note that memset does not return `dest`, like the libc API.
17// The semantics of memset is dictated by the corresponding
18// LLVM intrinsics, not by the libc API.
919export fn memset(dest: ?&u8, c: u8, n: usize) {
1020 @setDebugSafety(this, false);
1121
......@@ -14,6 +24,9 @@ export fn memset(dest: ?&u8, c: u8, n: usize) {
1424 (??dest)[index] = c;
1525}
1626
27// Note that memcpy does not return `dest`, like the libc API.
28// The semantics of memcpy is dictated by the corresponding
29// LLVM intrinsics, not by the libc API.
1730export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
1831 @setDebugSafety(this, false);
1932
std/special/compiler_rt/index.zig+10
......@@ -23,6 +23,16 @@ const assert = @import("../../debug.zig").assert;
2323
2424const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
2525
26// Avoid dragging in the debug safety mechanisms into this .o file,
27// unless we're trying to test this file.
28pub coldcc fn panic(msg: []const u8) -> noreturn {
29 if (is_test) {
30 @import("std").debug.panic("{}", msg);
31 } else {
32 unreachable;
33 }
34}
35
2636export fn __udivdi3(a: u64, b: u64) -> u64 {
2737 @setDebugSafety(this, is_test);
2838 @setGlobalLinkage(__udivdi3, builtin.GlobalLinkage.LinkOnce);
std/special/panic.zig created+14
......@@ -0,0 +1,14 @@
1// This file is the default panic handler if the root source file does not
2// have a `pub fn panic`.
3// If this file wants to import other files *by name*, support for that would
4// have to be added in the compiler.
5
6const builtin = @import("builtin");
7
8pub coldcc fn panic(msg: []const u8) -> noreturn {
9 if (builtin.os == builtin.Os.freestanding) {
10 while (true) {}
11 } else {
12 @import("std").debug.panic("{}", msg);
13 }
14}
std/special/zigrt.zig deleted-18
......@@ -1,18 +0,0 @@
1// This file contains functions that zig depends on to coordinate between
2// multiple .o files. The symbols are defined LinkOnce so that multiple
3// instances of zig_rt.zig do not conflict with each other.
4
5const builtin = @import("builtin");
6
7export coldcc fn __zig_panic(message_ptr: &const u8, message_len: usize) -> noreturn {
8 @setGlobalLinkage(__zig_panic, builtin.GlobalLinkage.LinkOnce);
9 @setDebugSafety(this, false);
10
11 if (builtin.__zig_panic_implementation_provided) {
12 @import("@root").panic(message_ptr[0..message_len]);
13 } else if (builtin.os == builtin.Os.freestanding) {
14 while (true) {}
15 } else {
16 @import("std").debug.panic("{}", message_ptr[0..message_len]);
17 }
18}
test/behavior.zig+1
......@@ -6,6 +6,7 @@ comptime {
66 _ = @import("cases/atomics.zig");
77 _ = @import("cases/bitcast.zig");
88 _ = @import("cases/bool.zig");
9 _ = @import("cases/bugs/394.zig");
910 _ = @import("cases/cast.zig");
1011 _ = @import("cases/const_slice_child.zig");
1112 _ = @import("cases/defer.zig");
test/cases/bugs/394.zig created+9
......@@ -0,0 +1,9 @@
1const E = enum { A: [9]u8, B: u64, };
2const S = struct { x: u8, y: E, };
3
4const assert = @import("std").debug.assert;
5
6test "bug 394 fixed" {
7 const x = S { .x = 3, .y = E.B {1} };
8 assert(x.x == 3);
9}