| author | |
| committer | |
| log | 98681b2da070755c29065d21d2ffb17be37d9619 |
| tree | cf9592ac47d5fd6d10557be65fb9d38c624728ee |
| parent | 7cc417644862a9b9523545f4455da7722afc8209 |
| parent | c3ae909e935f1548408f2e400464370ee02b7e82 |
| signature |
stage2: fix miscompilations for peer expressions any time they needed coercions to runtime types9 files changed, 78 insertions(+), 58 deletions(-)
lib/std/priority_queue.zig-15| ... | @@ -286,7 +286,6 @@ const PQlt = PriorityQueue(u32, void, lessThan); | ... | @@ -286,7 +286,6 @@ const PQlt = PriorityQueue(u32, void, lessThan); |
| 286 | const PQgt = PriorityQueue(u32, void, greaterThan); | 286 | const PQgt = PriorityQueue(u32, void, greaterThan); |
| 287 | 287 | ||
| 288 | test "std.PriorityQueue: add and remove min heap" { | 288 | test "std.PriorityQueue: add and remove min heap" { |
| 289 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 290 | var queue = PQlt.init(testing.allocator, {}); | 289 | var queue = PQlt.init(testing.allocator, {}); |
| 291 | defer queue.deinit(); | 290 | defer queue.deinit(); |
| 292 | 291 | ||
| ... | @@ -305,7 +304,6 @@ test "std.PriorityQueue: add and remove min heap" { | ... | @@ -305,7 +304,6 @@ test "std.PriorityQueue: add and remove min heap" { |
| 305 | } | 304 | } |
| 306 | 305 | ||
| 307 | test "std.PriorityQueue: add and remove same min heap" { | 306 | test "std.PriorityQueue: add and remove same min heap" { |
| 308 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 309 | var queue = PQlt.init(testing.allocator, {}); | 307 | var queue = PQlt.init(testing.allocator, {}); |
| 310 | defer queue.deinit(); | 308 | defer queue.deinit(); |
| 311 | 309 | ||
| ... | @@ -355,7 +353,6 @@ test "std.PriorityQueue: peek" { | ... | @@ -355,7 +353,6 @@ test "std.PriorityQueue: peek" { |
| 355 | } | 353 | } |
| 356 | 354 | ||
| 357 | test "std.PriorityQueue: sift up with odd indices" { | 355 | test "std.PriorityQueue: sift up with odd indices" { |
| 358 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 359 | var queue = PQlt.init(testing.allocator, {}); | 356 | var queue = PQlt.init(testing.allocator, {}); |
| 360 | defer queue.deinit(); | 357 | defer queue.deinit(); |
| 361 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 358 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -370,7 +367,6 @@ test "std.PriorityQueue: sift up with odd indices" { | ... | @@ -370,7 +367,6 @@ test "std.PriorityQueue: sift up with odd indices" { |
| 370 | } | 367 | } |
| 371 | 368 | ||
| 372 | test "std.PriorityQueue: addSlice" { | 369 | test "std.PriorityQueue: addSlice" { |
| 373 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 374 | var queue = PQlt.init(testing.allocator, {}); | 370 | var queue = PQlt.init(testing.allocator, {}); |
| 375 | defer queue.deinit(); | 371 | defer queue.deinit(); |
| 376 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 372 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -403,7 +399,6 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" { | ... | @@ -403,7 +399,6 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" { |
| 403 | } | 399 | } |
| 404 | 400 | ||
| 405 | test "std.PriorityQueue: fromOwnedSlice" { | 401 | test "std.PriorityQueue: fromOwnedSlice" { |
| 406 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; | ||
| 407 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 402 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| 408 | const heap_items = try testing.allocator.dupe(u32, items[0..]); | 403 | const heap_items = try testing.allocator.dupe(u32, items[0..]); |
| 409 | var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {}); | 404 | var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {}); |
| ... | @@ -416,7 +411,6 @@ test "std.PriorityQueue: fromOwnedSlice" { | ... | @@ -416,7 +411,6 @@ test "std.PriorityQueue: fromOwnedSlice" { |
| 416 | } | 411 | } |
| 417 | 412 | ||
| 418 | test "std.PriorityQueue: add and remove max heap" { | 413 | test "std.PriorityQueue: add and remove max heap" { |
| 419 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 420 | var queue = PQgt.init(testing.allocator, {}); | 414 | var queue = PQgt.init(testing.allocator, {}); |
| 421 | defer queue.deinit(); | 415 | defer queue.deinit(); |
| 422 | 416 | ||
| ... | @@ -435,7 +429,6 @@ test "std.PriorityQueue: add and remove max heap" { | ... | @@ -435,7 +429,6 @@ test "std.PriorityQueue: add and remove max heap" { |
| 435 | } | 429 | } |
| 436 | 430 | ||
| 437 | test "std.PriorityQueue: add and remove same max heap" { | 431 | test "std.PriorityQueue: add and remove same max heap" { |
| 438 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 439 | var queue = PQgt.init(testing.allocator, {}); | 432 | var queue = PQgt.init(testing.allocator, {}); |
| 440 | defer queue.deinit(); | 433 | defer queue.deinit(); |
| 441 | 434 | ||
| ... | @@ -476,7 +469,6 @@ test "std.PriorityQueue: iterator" { | ... | @@ -476,7 +469,6 @@ test "std.PriorityQueue: iterator" { |
| 476 | } | 469 | } |
| 477 | 470 | ||
| 478 | test "std.PriorityQueue: remove at index" { | 471 | test "std.PriorityQueue: remove at index" { |
| 479 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 480 | var queue = PQlt.init(testing.allocator, {}); | 472 | var queue = PQlt.init(testing.allocator, {}); |
| 481 | defer queue.deinit(); | 473 | defer queue.deinit(); |
| 482 | 474 | ||
| ... | @@ -512,7 +504,6 @@ test "std.PriorityQueue: iterator while empty" { | ... | @@ -512,7 +504,6 @@ test "std.PriorityQueue: iterator while empty" { |
| 512 | } | 504 | } |
| 513 | 505 | ||
| 514 | test "std.PriorityQueue: shrinkAndFree" { | 506 | test "std.PriorityQueue: shrinkAndFree" { |
| 515 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 516 | var queue = PQlt.init(testing.allocator, {}); | 507 | var queue = PQlt.init(testing.allocator, {}); |
| 517 | defer queue.deinit(); | 508 | defer queue.deinit(); |
| 518 | 509 | ||
| ... | @@ -536,7 +527,6 @@ test "std.PriorityQueue: shrinkAndFree" { | ... | @@ -536,7 +527,6 @@ test "std.PriorityQueue: shrinkAndFree" { |
| 536 | } | 527 | } |
| 537 | 528 | ||
| 538 | test "std.PriorityQueue: update min heap" { | 529 | test "std.PriorityQueue: update min heap" { |
| 539 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 540 | var queue = PQlt.init(testing.allocator, {}); | 530 | var queue = PQlt.init(testing.allocator, {}); |
| 541 | defer queue.deinit(); | 531 | defer queue.deinit(); |
| 542 | 532 | ||
| ... | @@ -552,7 +542,6 @@ test "std.PriorityQueue: update min heap" { | ... | @@ -552,7 +542,6 @@ test "std.PriorityQueue: update min heap" { |
| 552 | } | 542 | } |
| 553 | 543 | ||
| 554 | test "std.PriorityQueue: update same min heap" { | 544 | test "std.PriorityQueue: update same min heap" { |
| 555 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 556 | var queue = PQlt.init(testing.allocator, {}); | 545 | var queue = PQlt.init(testing.allocator, {}); |
| 557 | defer queue.deinit(); | 546 | defer queue.deinit(); |
| 558 | 547 | ||
| ... | @@ -569,7 +558,6 @@ test "std.PriorityQueue: update same min heap" { | ... | @@ -569,7 +558,6 @@ test "std.PriorityQueue: update same min heap" { |
| 569 | } | 558 | } |
| 570 | 559 | ||
| 571 | test "std.PriorityQueue: update max heap" { | 560 | test "std.PriorityQueue: update max heap" { |
| 572 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 573 | var queue = PQgt.init(testing.allocator, {}); | 561 | var queue = PQgt.init(testing.allocator, {}); |
| 574 | defer queue.deinit(); | 562 | defer queue.deinit(); |
| 575 | 563 | ||
| ... | @@ -585,7 +573,6 @@ test "std.PriorityQueue: update max heap" { | ... | @@ -585,7 +573,6 @@ test "std.PriorityQueue: update max heap" { |
| 585 | } | 573 | } |
| 586 | 574 | ||
| 587 | test "std.PriorityQueue: update same max heap" { | 575 | test "std.PriorityQueue: update same max heap" { |
| 588 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 589 | var queue = PQgt.init(testing.allocator, {}); | 576 | var queue = PQgt.init(testing.allocator, {}); |
| 590 | defer queue.deinit(); | 577 | defer queue.deinit(); |
| 591 | 578 | ||
| ... | @@ -602,7 +589,6 @@ test "std.PriorityQueue: update same max heap" { | ... | @@ -602,7 +589,6 @@ test "std.PriorityQueue: update same max heap" { |
| 602 | } | 589 | } |
| 603 | 590 | ||
| 604 | test "std.PriorityQueue: siftUp in remove" { | 591 | test "std.PriorityQueue: siftUp in remove" { |
| 605 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 606 | var queue = PQlt.init(testing.allocator, {}); | 592 | var queue = PQlt.init(testing.allocator, {}); |
| 607 | defer queue.deinit(); | 593 | defer queue.deinit(); |
| 608 | 594 | ||
| ... | @@ -623,7 +609,6 @@ fn contextLessThan(context: []const u32, a: usize, b: usize) Order { | ... | @@ -623,7 +609,6 @@ fn contextLessThan(context: []const u32, a: usize, b: usize) Order { |
| 623 | const CPQlt = PriorityQueue(usize, []const u32, contextLessThan); | 609 | const CPQlt = PriorityQueue(usize, []const u32, contextLessThan); |
| 624 | 610 | ||
| 625 | test "std.PriorityQueue: add and remove min heap with contextful comparator" { | 611 | test "std.PriorityQueue: add and remove min heap with contextful comparator" { |
| 626 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 627 | const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 }; | 612 | const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 }; |
| 628 | 613 | ||
| 629 | var queue = CPQlt.init(testing.allocator, context[0..]); | 614 | var queue = CPQlt.init(testing.allocator, context[0..]); |
src/AstGen.zig+1-1| ... | @@ -10007,7 +10007,7 @@ const GenZir = struct { | ... | @@ -10007,7 +10007,7 @@ const GenZir = struct { |
| 10007 | .inferred_ptr => |ptr| { | 10007 | .inferred_ptr => |ptr| { |
| 10008 | gz.rl_ty_inst = .none; | 10008 | gz.rl_ty_inst = .none; |
| 10009 | gz.rl_ptr = ptr; | 10009 | gz.rl_ptr = ptr; |
| 10010 | gz.break_result_loc = parent_rl; | 10010 | gz.break_result_loc = .{ .block_ptr = gz }; |
| 10011 | }, | 10011 | }, |
| 10012 | 10012 | ||
| 10013 | .block_ptr => |parent_block_scope| { | 10013 | .block_ptr => |parent_block_scope| { |
src/Sema.zig+1-22| ... | @@ -3079,28 +3079,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3079,28 +3079,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3079 | 3079 | ||
| 3080 | if (var_is_mut) { | 3080 | if (var_is_mut) { |
| 3081 | try sema.validateVarType(block, ty_src, final_elem_ty, false); | 3081 | try sema.validateVarType(block, ty_src, final_elem_ty, false); |
| 3082 | |||
| 3083 | // The value might have been bitcasted into a comptime only | ||
| 3084 | // pointer type such as `*@Type(.EnumLiteral)` so we must now | ||
| 3085 | // update all the stores to not give backends invalid AIR. | ||
| 3086 | |||
| 3087 | var air_tags = sema.air_instructions.items(.tag); | ||
| 3088 | var air_data = sema.air_instructions.items(.data); | ||
| 3089 | var peer_inst_index: usize = 0; | ||
| 3090 | var i = ptr_inst; | ||
| 3091 | while (i < air_tags.len and peer_inst_index < peer_inst_list.len) : (i += 1) { | ||
| 3092 | if (air_tags[i] != .store) continue; | ||
| 3093 | if (air_data[i].bin_op.rhs == peer_inst_list[peer_inst_index]) { | ||
| 3094 | peer_inst_index += 1; | ||
| 3095 | _ = (try sema.resolveMaybeUndefVal(block, .unneeded, air_data[i].bin_op.rhs)) orelse continue; | ||
| 3096 | const coerced_val = try sema.coerce(block, final_elem_ty, air_data[i].bin_op.rhs, .unneeded); | ||
| 3097 | air_tags = sema.air_instructions.items(.tag); | ||
| 3098 | air_data = sema.air_instructions.items(.data); | ||
| 3099 | |||
| 3100 | air_data[i].bin_op.lhs = ptr; | ||
| 3101 | air_data[i].bin_op.rhs = coerced_val; | ||
| 3102 | } | ||
| 3103 | } | ||
| 3104 | } else ct: { | 3082 | } else ct: { |
| 3105 | // Detect if the value is comptime known. In such case, the | 3083 | // Detect if the value is comptime known. In such case, the |
| 3106 | // last 3 AIR instructions of the block will look like this: | 3084 | // last 3 AIR instructions of the block will look like this: |
| ... | @@ -4478,6 +4456,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -4478,6 +4456,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro |
| 4478 | .label = &label, | 4456 | .label = &label, |
| 4479 | .inlining = parent_block.inlining, | 4457 | .inlining = parent_block.inlining, |
| 4480 | .is_comptime = parent_block.is_comptime, | 4458 | .is_comptime = parent_block.is_comptime, |
| 4459 | .want_safety = parent_block.want_safety, | ||
| 4481 | }; | 4460 | }; |
| 4482 | 4461 | ||
| 4483 | defer child_block.instructions.deinit(gpa); | 4462 | defer child_block.instructions.deinit(gpa); |
src/TypedValue.zig+55-7| ... | @@ -427,15 +427,63 @@ pub fn print( | ... | @@ -427,15 +427,63 @@ pub fn print( |
| 427 | }, | 427 | }, |
| 428 | .eu_payload_ptr => { | 428 | .eu_payload_ptr => { |
| 429 | try writer.writeAll("&"); | 429 | try writer.writeAll("&"); |
| 430 | val = val.castTag(.eu_payload_ptr).?.data.container_ptr; | 430 | |
| 431 | ty = ty.elemType2().errorUnionPayload(); | 431 | const data = val.castTag(.eu_payload_ptr).?.data; |
| 432 | |||
| 433 | var ty_val: Value.Payload.Ty = .{ | ||
| 434 | .base = .{ .tag = .ty }, | ||
| 435 | .data = ty, | ||
| 436 | }; | ||
| 437 | |||
| 438 | try writer.writeAll("@as("); | ||
| 439 | try print(.{ | ||
| 440 | .ty = Type.type, | ||
| 441 | .val = Value.initPayload(&ty_val.base), | ||
| 442 | }, writer, level - 1, mod); | ||
| 443 | |||
| 444 | try writer.writeAll(", &(payload of "); | ||
| 445 | |||
| 446 | var ptr_ty: Type.Payload.ElemType = .{ | ||
| 447 | .base = .{ .tag = .single_mut_pointer }, | ||
| 448 | .data = data.container_ty, | ||
| 449 | }; | ||
| 450 | |||
| 451 | try print(.{ | ||
| 452 | .ty = Type.initPayload(&ptr_ty.base), | ||
| 453 | .val = data.container_ptr, | ||
| 454 | }, writer, level - 1, mod); | ||
| 455 | |||
| 456 | try writer.writeAll("))"); | ||
| 457 | return; | ||
| 432 | }, | 458 | }, |
| 433 | .opt_payload_ptr => { | 459 | .opt_payload_ptr => { |
| 434 | try writer.writeAll("&"); | 460 | const data = val.castTag(.opt_payload_ptr).?.data; |
| 435 | val = val.castTag(.opt_payload).?.data; | 461 | |
| 436 | var buf: Type.Payload.ElemType = undefined; | 462 | var ty_val: Value.Payload.Ty = .{ |
| 437 | ty = ty.elemType2().optionalChild(&buf); | 463 | .base = .{ .tag = .ty }, |
| 438 | return print(.{ .ty = ty, .val = val }, writer, level, mod); | 464 | .data = ty, |
| 465 | }; | ||
| 466 | |||
| 467 | try writer.writeAll("@as("); | ||
| 468 | try print(.{ | ||
| 469 | .ty = Type.type, | ||
| 470 | .val = Value.initPayload(&ty_val.base), | ||
| 471 | }, writer, level - 1, mod); | ||
| 472 | |||
| 473 | try writer.writeAll(", &(payload of "); | ||
| 474 | |||
| 475 | var ptr_ty: Type.Payload.ElemType = .{ | ||
| 476 | .base = .{ .tag = .single_mut_pointer }, | ||
| 477 | .data = data.container_ty, | ||
| 478 | }; | ||
| 479 | |||
| 480 | try print(.{ | ||
| 481 | .ty = Type.initPayload(&ptr_ty.base), | ||
| 482 | .val = data.container_ptr, | ||
| 483 | }, writer, level - 1, mod); | ||
| 484 | |||
| 485 | try writer.writeAll("))"); | ||
| 486 | return; | ||
| 439 | }, | 487 | }, |
| 440 | 488 | ||
| 441 | // TODO these should not appear in this function | 489 | // TODO these should not appear in this function |
src/print_zir.zig+1| ... | @@ -2217,6 +2217,7 @@ const Writer = struct { | ... | @@ -2217,6 +2217,7 @@ const Writer = struct { |
| 2217 | 2217 | ||
| 2218 | fn writeUnreachable(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2218 | fn writeUnreachable(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { |
| 2219 | const inst_data = self.code.instructions.items(.data)[inst].@"unreachable"; | 2219 | const inst_data = self.code.instructions.items(.data)[inst].@"unreachable"; |
| 2220 | try stream.writeAll(") "); | ||
| 2220 | try self.writeSrc(stream, inst_data.src()); | 2221 | try self.writeSrc(stream, inst_data.src()); |
| 2221 | } | 2222 | } |
| 2222 | 2223 |
test/behavior/basic.zig-12| ... | @@ -928,18 +928,6 @@ test "try in labeled block doesn't cast to wrong type" { | ... | @@ -928,18 +928,6 @@ test "try in labeled block doesn't cast to wrong type" { |
| 928 | _ = s; | 928 | _ = s; |
| 929 | } | 929 | } |
| 930 | 930 | ||
| 931 | test "comptime int in switch in catch is casted to correct inferred type" { | ||
| 932 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 933 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 934 | |||
| 935 | var a: error{ A, B }!u64 = 0; | ||
| 936 | var b = a catch |err| switch (err) { | ||
| 937 | error.A => 0, | ||
| 938 | else => unreachable, | ||
| 939 | }; | ||
| 940 | _ = b; | ||
| 941 | } | ||
| 942 | |||
| 943 | test "vector initialized with array init syntax has proper type" { | 931 | test "vector initialized with array init syntax has proper type" { |
| 944 | comptime { | 932 | comptime { |
| 945 | const actual = -@Vector(4, i32){ 1, 2, 3, 4 }; | 933 | const actual = -@Vector(4, i32){ 1, 2, 3, 4 }; |
test/behavior/cast.zig+2| ... | @@ -812,6 +812,7 @@ test "peer type resolution: error union after non-error" { | ... | @@ -812,6 +812,7 @@ test "peer type resolution: error union after non-error" { |
| 812 | } | 812 | } |
| 813 | 813 | ||
| 814 | test "peer cast *[0]T to E![]const T" { | 814 | test "peer cast *[0]T to E![]const T" { |
| 815 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 815 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 816 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 816 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 817 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 817 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | 818 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| ... | @@ -826,6 +827,7 @@ test "peer cast *[0]T to E![]const T" { | ... | @@ -826,6 +827,7 @@ test "peer cast *[0]T to E![]const T" { |
| 826 | } | 827 | } |
| 827 | 828 | ||
| 828 | test "peer cast *[0]T to []const T" { | 829 | test "peer cast *[0]T to []const T" { |
| 830 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 829 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 831 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 830 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 832 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 831 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | 833 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
test/behavior/error.zig+1-1| ... | @@ -709,7 +709,7 @@ test "simple else prong allowed even when all errors handled" { | ... | @@ -709,7 +709,7 @@ test "simple else prong allowed even when all errors handled" { |
| 709 | } | 709 | } |
| 710 | }; | 710 | }; |
| 711 | var value = S.foo() catch |err| switch (err) { | 711 | var value = S.foo() catch |err| switch (err) { |
| 712 | error.Foo => 255, | 712 | error.Foo => @as(u8, 255), |
| 713 | else => |e| return e, | 713 | else => |e| return e, |
| 714 | }; | 714 | }; |
| 715 | try expect(value == 255); | 715 | try expect(value == 255); |
test/behavior/if.zig+17| ... | @@ -111,3 +111,20 @@ test "if prongs cast to expected type instead of peer type resolution" { | ... | @@ -111,3 +111,20 @@ test "if prongs cast to expected type instead of peer type resolution" { |
| 111 | try S.doTheTest(false); | 111 | try S.doTheTest(false); |
| 112 | comptime try S.doTheTest(false); | 112 | comptime try S.doTheTest(false); |
| 113 | } | 113 | } |
| 114 | |||
| 115 | test "if peer expressions inferred optional type" { | ||
| 116 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 117 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 118 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 119 | |||
| 120 | var self: []const u8 = "abcdef"; | ||
| 121 | var index: usize = 0; | ||
| 122 | var left_index = (index << 1) + 1; | ||
| 123 | var right_index = left_index + 1; | ||
| 124 | var left = if (left_index < self.len) self[left_index] else null; | ||
| 125 | var right = if (right_index < self.len) self[right_index] else null; | ||
| 126 | try expect(left_index < self.len); | ||
| 127 | try expect(right_index < self.len); | ||
| 128 | try expect(left.? == 98); | ||
| 129 | try expect(right.? == 99); | ||
| 130 | } |