| author | |
| committer | |
| log | 3d53a95718bbf7abd17cf69c623aff4e9a97a0b4 |
| tree | ead092735b3f110f9b0ff9dcdaab262266fc08b3 |
| parent | c49ab049c590d51661654084062f9f067c73fda0 |
| parent | ec889d5888c57d0337a1e00398d71241a9716ebe |
| signature | Commit is signed but in an unrecognized format. |
4 files changed, 29 insertions(+), 4 deletions(-)
lib/std/fs.zig+1| ... | ... | @@ -864,6 +864,7 @@ pub const Dir = struct { |
| 864 | 864 | .OBJECT_NAME_INVALID => unreachable, |
| 865 | 865 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, |
| 866 | 866 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, |
| 867 | .NO_MEDIA_IN_DEVICE => return error.NoDevice, | |
| 867 | 868 | .INVALID_PARAMETER => unreachable, |
| 868 | 869 | .SHARING_VIOLATION => return error.SharingViolation, |
| 869 | 870 | .ACCESS_DENIED => return error.AccessDenied, |
src/ir.cpp+12-2| ... | ... | @@ -26677,9 +26677,19 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 26677 | 26677 | |
| 26678 | 26678 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 26679 | 26679 | return_type, nullptr, true, true); |
| 26680 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { | |
| 26681 | return result_loc; | |
| 26680 | ||
| 26681 | if (result_loc != nullptr) { | |
| 26682 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { | |
| 26683 | return result_loc; | |
| 26684 | } | |
| 26685 | IrInstGen *dummy_value = ir_const(ira, &instruction->base.base, return_type); | |
| 26686 | dummy_value->value->special = ConstValSpecialRuntime; | |
| 26687 | IrInstGen *dummy_result = ir_implicit_cast2(ira, &instruction->base.base, | |
| 26688 | dummy_value, result_loc->value->type->data.pointer.child_type); | |
| 26689 | if (type_is_invalid(dummy_result->value->type)) | |
| 26690 | return ira->codegen->invalid_inst_gen; | |
| 26682 | 26691 | } |
| 26692 | ||
| 26683 | 26693 | return ir_build_slice_gen(ira, &instruction->base.base, return_type, |
| 26684 | 26694 | ptr_ptr, casted_start, end, instruction->safety_check_on, result_loc); |
| 26685 | 26695 | } |
test/compile_errors.zig+12| ... | ... | @@ -3,6 +3,18 @@ const builtin = @import("builtin"); |
| 3 | 3 | const Target = @import("std").Target; |
| 4 | 4 | |
| 5 | 5 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6 | cases.addTest("slice to pointer conversion mismatch", | |
| 7 | \\pub fn bytesAsSlice(bytes: var) [*]align(1) const u16 { | |
| 8 | \\ return @ptrCast([*]align(1) const u16, bytes.ptr)[0..1]; | |
| 9 | \\} | |
| 10 | \\test "bytesAsSlice" { | |
| 11 | \\ const bytes = [_]u8{ 0xDE, 0xAD, 0xBE, 0xEF }; | |
| 12 | \\ const slice = bytesAsSlice(bytes[0..]); | |
| 13 | \\} | |
| 14 | , &[_][]const u8{ | |
| 15 | "tmp.zig:2:54: error: expected type '[*]align(1) const u16', found '[]align(1) const u16'", | |
| 16 | }); | |
| 17 | ||
| 6 | 18 | cases.addTest("access invalid @typeInfo decl", |
| 7 | 19 | \\const A = B; |
| 8 | 20 | \\test "Crash" { |
test/tests.zig+4-2| ... | ... | @@ -677,8 +677,10 @@ pub const StackTracesContext = struct { |
| 677 | 677 | const got: []const u8 = got_result: { |
| 678 | 678 | var buf = try Buffer.initSize(b.allocator, 0); |
| 679 | 679 | defer buf.deinit(); |
| 680 | var bytes = stderr.toSliceConst(); | |
| 681 | if (bytes.len != 0 and bytes[bytes.len - 1] == '\n') bytes = bytes[0 .. bytes.len - 1]; | |
| 680 | const bytes = if (stderr.endsWith("\n")) | |
| 681 | stderr.toSliceConst()[0 .. stderr.len() - 1] | |
| 682 | else | |
| 683 | stderr.toSliceConst()[0..stderr.len()]; | |
| 682 | 684 | var it = mem.separate(bytes, "\n"); |
| 683 | 685 | process_lines: while (it.next()) |line| { |
| 684 | 686 | if (line.len == 0) continue; |