| author | |
| committer | |
| log | ba62853d26f6a3388a7ad099a1d9091d7eca45c9 |
| tree | 7472c1c2cebe24fb4fc3283343ae18e36d87d153 |
| parent | cd32b11eb8d33225a1a2bc3bc9e0755936a39ade |
| signature |
I didn't realize that the `array` value type has the sentinel on it.2 files changed, 20 insertions(+), 13 deletions(-)
src/Sema.zig+5-10| ... | @@ -11827,21 +11827,16 @@ fn zirArrayInit( | ... | @@ -11827,21 +11827,16 @@ fn zirArrayInit( |
| 11827 | }); | 11827 | }); |
| 11828 | }; | 11828 | }; |
| 11829 | 11829 | ||
| 11830 | const elems = if (!is_sent) | 11830 | const opt_runtime_src: ?LazySrcLoc = for (resolved_args) |arg| { |
| 11831 | resolved_args | ||
| 11832 | else | ||
| 11833 | resolved_args[0 .. resolved_args.len - 1]; | ||
| 11834 | |||
| 11835 | const opt_runtime_src: ?LazySrcLoc = for (elems) |arg| { | ||
| 11836 | const arg_src = src; // TODO better source location | 11831 | const arg_src = src; // TODO better source location |
| 11837 | const comptime_known = try sema.isComptimeKnown(block, arg_src, arg); | 11832 | const comptime_known = try sema.isComptimeKnown(block, arg_src, arg); |
| 11838 | if (!comptime_known) break arg_src; | 11833 | if (!comptime_known) break arg_src; |
| 11839 | } else null; | 11834 | } else null; |
| 11840 | 11835 | ||
| 11841 | const runtime_src = opt_runtime_src orelse { | 11836 | const runtime_src = opt_runtime_src orelse { |
| 11842 | const elem_vals = try sema.arena.alloc(Value, elems.len); | 11837 | const elem_vals = try sema.arena.alloc(Value, resolved_args.len); |
| 11843 | 11838 | ||
| 11844 | for (elems) |arg, i| { | 11839 | for (resolved_args) |arg, i| { |
| 11845 | // We checked that all args are comptime above. | 11840 | // We checked that all args are comptime above. |
| 11846 | elem_vals[i] = (sema.resolveMaybeUndefVal(block, src, arg) catch unreachable).?; | 11841 | elem_vals[i] = (sema.resolveMaybeUndefVal(block, src, arg) catch unreachable).?; |
| 11847 | } | 11842 | } |
| ... | @@ -11868,7 +11863,7 @@ fn zirArrayInit( | ... | @@ -11868,7 +11863,7 @@ fn zirArrayInit( |
| 11868 | }); | 11863 | }); |
| 11869 | const elem_ptr_ty_ref = try sema.addType(elem_ptr_ty); | 11864 | const elem_ptr_ty_ref = try sema.addType(elem_ptr_ty); |
| 11870 | 11865 | ||
| 11871 | for (elems) |arg, i| { | 11866 | for (resolved_args) |arg, i| { |
| 11872 | const index = try sema.addIntUnsigned(Type.usize, i); | 11867 | const index = try sema.addIntUnsigned(Type.usize, i); |
| 11873 | const elem_ptr = try block.addPtrElemPtrTypeRef(alloc, index, elem_ptr_ty_ref); | 11868 | const elem_ptr = try block.addPtrElemPtrTypeRef(alloc, index, elem_ptr_ty_ref); |
| 11874 | _ = try block.addBinOp(.store, elem_ptr, arg); | 11869 | _ = try block.addBinOp(.store, elem_ptr, arg); |
| ... | @@ -11876,7 +11871,7 @@ fn zirArrayInit( | ... | @@ -11876,7 +11871,7 @@ fn zirArrayInit( |
| 11876 | return alloc; | 11871 | return alloc; |
| 11877 | } | 11872 | } |
| 11878 | 11873 | ||
| 11879 | return block.addAggregateInit(array_ty, elems); | 11874 | return block.addAggregateInit(array_ty, resolved_args); |
| 11880 | } | 11875 | } |
| 11881 | 11876 | ||
| 11882 | fn zirArrayInitAnon( | 11877 | fn zirArrayInitAnon( |
test/behavior/pointers.zig+15-3| ... | @@ -317,7 +317,11 @@ test "allow any sentinel" { | ... | @@ -317,7 +317,11 @@ test "allow any sentinel" { |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | test "pointer sentinel with enums" { | 319 | test "pointer sentinel with enums" { |
| 320 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 320 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 321 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 322 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 323 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 324 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 321 | 325 | ||
| 322 | const S = struct { | 326 | const S = struct { |
| 323 | const Number = enum { | 327 | const Number = enum { |
| ... | @@ -336,7 +340,11 @@ test "pointer sentinel with enums" { | ... | @@ -336,7 +340,11 @@ test "pointer sentinel with enums" { |
| 336 | } | 340 | } |
| 337 | 341 | ||
| 338 | test "pointer sentinel with optional element" { | 342 | test "pointer sentinel with optional element" { |
| 339 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 343 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 344 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 345 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 346 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 347 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 340 | 348 | ||
| 341 | const S = struct { | 349 | const S = struct { |
| 342 | fn doTheTest() !void { | 350 | fn doTheTest() !void { |
| ... | @@ -349,7 +357,11 @@ test "pointer sentinel with optional element" { | ... | @@ -349,7 +357,11 @@ test "pointer sentinel with optional element" { |
| 349 | } | 357 | } |
| 350 | 358 | ||
| 351 | test "pointer sentinel with +inf" { | 359 | test "pointer sentinel with +inf" { |
| 352 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 360 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 361 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 362 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 363 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 364 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 353 | 365 | ||
| 354 | const S = struct { | 366 | const S = struct { |
| 355 | fn doTheTest() !void { | 367 | fn doTheTest() !void { |