diff --git a/src/stage1.zig b/src/stage1.zig index d07a1c199c23faef606a93d12536d49ff19d1ed2..2dabea91aded8a90dd772ae29ab01cf21f72fb68 100644 --- a/src/stage1.zig +++ b/src/stage1.zig @@ -428,5 +428,7 @@ export fn stage2_fetch_file( const max_file_size = std.math.maxInt(u32); const contents = comp.stage1_cache_manifest.addFilePostFetch(file_path, max_file_size) catch return null; result_len.* = contents.len; + // TODO https://github.com/ziglang/zig/issues/3328#issuecomment-716749475 + if (contents.len == 0) return @intToPtr(?[*]const u8, 0x1); return contents.ptr; } diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp index 04c064efe394a6be189047df5a26048a8f172494..fd0de8e907c0c150f3620c759ec6003518488c9b 100644 --- a/src/stage1/analyze.cpp +++ b/src/stage1/analyze.cpp @@ -1988,7 +1988,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc // behaviour when checking expected alignment with `@ptrToInt(fn_ptr)` // or similar. This commit proposes to make `align` expressions a // compile error when compiled to Wasm architecture. - // + // // Some references: // [1] [Mozilla: WebAssembly Tables](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables) // [2] [Sunfishcode's Wasm Ref Manual](https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#indirect-call) @@ -9044,7 +9044,7 @@ static void resolve_llvm_types_optional(CodeGen *g, ZigType *type, ResolveStatus 8 * child_type->abi_align, val_offset_in_bits, ZigLLVM_DIFlags_Zero, child_llvm_di_type); - di_element_types[maybe_null_index] = + di_element_types[maybe_null_index] = ZigLLVMCreateDebugMemberType(g->dbuilder, ZigLLVMTypeToScope(type->llvm_di_type), "maybe", di_file, line, 8*g->builtin_types.entry_bool->abi_size, diff --git a/test/stage1/behavior/import.zig b/test/stage1/behavior/import.zig index 2aa2ec4e600443b997417c1981183556d77dd513..30655554bf6381e924212f7b416c31df0701b328 100644 --- a/test/stage1/behavior/import.zig +++ b/test/stage1/behavior/import.zig @@ -16,3 +16,7 @@ test "import in non-toplevel scope" { }; expectEqual(@as(i32, 1234), S.foo()); } + +test "import empty file" { + const empty = @import("import/empty.zig"); +} diff --git a/test/stage1/behavior/import/empty.zig b/test/stage1/behavior/import/empty.zig new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391