commit e2caf5752791cb81cd1110617d646e87f360e11b (tree)
parent c1ae9f40c728e769e804eabfcab0b40d6c0f67f2
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 26 Oct 2020 16:07:46 -0700
Merge branch 'frmdstryr-import-empty-file'
Diffstat:
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git 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
@@ -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
@@ -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