Commit fa34dfcce7

Andrew Kelley <andrew@ziglang.org>
2019-11-07 20:46:48
fix result loc of cast not finding parent
1 parent e0db54e
Changed files (3)
src
test
stage1
src/ir.cpp
@@ -15733,7 +15733,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
                 casted_value = nullptr;
             }
 
-            if (casted_value == nullptr || type_is_invalid(casted_value->value.type)) {
+            if (casted_value != nullptr && type_is_invalid(casted_value->value.type)) {
                 return casted_value;
             }
 
test/stage1/behavior/misc.zig
@@ -241,14 +241,14 @@ fn memFree(comptime T: type, memory: []T) void {}
 
 test "cast undefined" {
     const array: [100]u8 = undefined;
-    const slice = ([]const u8)(array);
+    const slice = @as([]const u8, array);
     testCastUndefined(slice);
 }
 fn testCastUndefined(x: []const u8) void {}
 
 test "cast small unsigned to larger signed" {
-    expect(castSmallUnsignedToLargerSigned1(200) == i16(200));
-    expect(castSmallUnsignedToLargerSigned2(9999) == i64(9999));
+    expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200));
+    expect(castSmallUnsignedToLargerSigned2(9999) == @as(i64, 9999));
 }
 fn castSmallUnsignedToLargerSigned1(x: u8) i16 {
     return x;
@@ -350,7 +350,7 @@ fn testTakeAddressOfParameter(f: f32) void {
 }
 
 test "pointer comparison" {
-    const a = ([]const u8)("a");
+    const a = @as([]const u8, "a");
     const b = &a;
     expect(ptrEql(b, b));
 }
@@ -642,7 +642,7 @@ test "self reference through fn ptr field" {
 
 test "volatile load and store" {
     var number: i32 = 1234;
-    const ptr = (*volatile i32)(&number);
+    const ptr = @as(*volatile i32, &number);
     ptr.* += 1;
     expect(ptr.* == 1235);
 }
test/stage1/behavior.zig
@@ -1,5 +1,5 @@
 comptime {
-    //_ = @import("behavior/align.zig");
+    _ = @import("behavior/align.zig");
     _ = @import("behavior/alignof.zig");
     //_ = @import("behavior/array.zig");
     _ = @import("behavior/asm.zig");
@@ -73,7 +73,7 @@ comptime {
     _ = @import("behavior/ir_block_deps.zig");
     _ = @import("behavior/math.zig");
     _ = @import("behavior/merge_error_sets.zig");
-    //_ = @import("behavior/misc.zig");
+    _ = @import("behavior/misc.zig");
     _ = @import("behavior/muladd.zig");
     _ = @import("behavior/namespace_depends_on_compile_var.zig");
     _ = @import("behavior/new_stack_call.zig");