authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-21 23:24:58-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-21 23:25:02-05:00
logad0871ea4bf2dfbed07282ffe14738b5347d5d32
tree17497337d26c37cf2bbc7d68d2813c22fea5c661
parent94299d16d1443cd8b731e2eba9b4d1e3fb8048bd
parent4e6c1b676b30920fb333a6aa270bb42dc4cecc79
signaturelock-open Commit is signed but in an unrecognized format.

Merge branch 'Vexu-missing-cast'

Closes #3336 Closes #3718

5 files changed, 34 insertions(+), 13 deletions(-)

lib/std/child_process.zig+1-1
......@@ -63,7 +63,7 @@ pub const ChildProcess = struct {
6363
6464 /// Windows-only. `cwd` was provided, but the path did not exist when spawning the child process.
6565 CurrentWorkingDirectoryUnlinked,
66 } || os.ExecveError || os.SetIdError || os.ChangeCurDirError || windows.CreateProcessError;
66 } || os.ExecveError || os.SetIdError || os.ChangeCurDirError || windows.CreateProcessError || windows.WaitForSingleObjectError;
6767
6868 pub const Term = union(enum) {
6969 Exited: u32,
lib/std/coff.zig+1-1
......@@ -179,7 +179,7 @@ pub const Coff = struct {
179179 if (byte != 0 and i == buffer.len)
180180 return error.NameTooLong;
181181
182 return i;
182 return @as(usize, i);
183183 }
184184
185185 pub fn loadSections(self: *Coff) !void {
src/codegen.cpp+1-1
......@@ -7725,7 +7725,7 @@ static void do_code_gen(CodeGen *g) {
77257725
77267726 char *error = nullptr;
77277727 if (LLVMVerifyModule(g->module, LLVMReturnStatusAction, &error)) {
7728 zig_panic("broken LLVM module found: %s", error);
7728 zig_panic("broken LLVM module found: %s\nThis is a bug in the Zig compiler.", error);
77297729 }
77307730}
77317731
src/ir.cpp+10-10
......@@ -13535,16 +13535,6 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio
1353513535 if (type_is_invalid(operand->value.type))
1353613536 return ir_unreach_error(ira);
1353713537
13538 if (!instr_is_comptime(operand) && ira->explicit_return_type != nullptr &&
13539 handle_is_ptr(ira->explicit_return_type))
13540 {
13541 // result location mechanism took care of it.
13542 IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope,
13543 instruction->base.source_node, nullptr);
13544 result->value.type = ira->codegen->builtin_types.entry_unreachable;
13545 return ir_finish_anal(ira, result);
13546 }
13547
1354813538 IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type);
1354913539 if (type_is_invalid(casted_operand->value.type)) {
1355013540 AstNode *source_node = ira->explicit_return_type_source_node;
......@@ -13556,6 +13546,16 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio
1355613546 return ir_unreach_error(ira);
1355713547 }
1355813548
13549 if (!instr_is_comptime(operand) && ira->explicit_return_type != nullptr &&
13550 handle_is_ptr(ira->explicit_return_type))
13551 {
13552 // result location mechanism took care of it.
13553 IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope,
13554 instruction->base.source_node, nullptr);
13555 result->value.type = ira->codegen->builtin_types.entry_unreachable;
13556 return ir_finish_anal(ira, result);
13557 }
13558
1355913559 if (casted_operand->value.special == ConstValSpecialRuntime &&
1356013560 casted_operand->value.type->id == ZigTypeIdPointer &&
1356113561 casted_operand->value.data.rh_ptr == RuntimeHintPtrStack)
test/compile_errors.zig+21
......@@ -12,6 +12,27 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1212 "tmp.zig:3:5: error: switch must handle all possibilities",
1313 );
1414
15 cases.add(
16 "incorrect return type",
17 \\ pub export fn entry() void{
18 \\ _ = foo();
19 \\ }
20 \\ const A = struct {
21 \\ a: u32,
22 \\ };
23 \\ fn foo() A {
24 \\ return bar();
25 \\ }
26 \\ const B = struct {
27 \\ a: u32,
28 \\ };
29 \\ fn bar() B {
30 \\ unreachable;
31 \\ }
32 ,
33 "tmp.zig:8:16: error: expected type 'A', found 'B'",
34 );
35
1536 cases.add(
1637 "regression test #2980: base type u32 is not type checked properly when assigning a value within a struct",
1738 \\const Foo = struct {