| author | |
| committer | |
| log | 92beb2b490d7d86825d2e0eae3287c06477c9e81 |
| tree | db759eb5a68383b3ffd92a5e08acbe54d689416b |
| parent | 923b07bac797d66fe6d393cf823402c742250f48 |
5 files changed, 35 insertions(+), 21 deletions(-)
lib/std/math.zig+4-3| ... | ... | @@ -947,7 +947,7 @@ fn testRem() !void { |
| 947 | 947 | /// Result is an unsigned integer. |
| 948 | 948 | pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { |
| 949 | 949 | .ComptimeInt => comptime_int, |
| 950 | .Int => |intInfo| std.meta.Int(.unsigned, intInfo.bits), | |
| 950 | .Int => |int_info| std.meta.Int(.unsigned, int_info.bits), | |
| 951 | 951 | else => @compileError("absCast only accepts integers"), |
| 952 | 952 | } { |
| 953 | 953 | switch (@typeInfo(@TypeOf(x))) { |
| ... | ... | @@ -958,8 +958,9 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { |
| 958 | 958 | return x; |
| 959 | 959 | } |
| 960 | 960 | }, |
| 961 | .Int => |intInfo| { | |
| 962 | const Uint = std.meta.Int(.unsigned, intInfo.bits); | |
| 961 | .Int => |int_info| { | |
| 962 | if (int_info.signedness == .unsigned) return x; | |
| 963 | const Uint = std.meta.Int(.unsigned, int_info.bits); | |
| 963 | 964 | if (x < 0) { |
| 964 | 965 | return ~@bitCast(Uint, x +% -1); |
| 965 | 966 | } else { |
src/Sema.zig+14-7| ... | ... | @@ -3351,9 +3351,10 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v |
| 3351 | 3351 | // Check for the possibility of this pattern: |
| 3352 | 3352 | // %a = ret_ptr |
| 3353 | 3353 | // %b = store(%a, %c) |
| 3354 | // Where %c is an error union. In such case we need to add to the current function's | |
| 3355 | // inferred error set, if any. | |
| 3356 | if (sema.typeOf(operand).zigTypeTag() == .ErrorUnion and | |
| 3354 | // Where %c is an error union or error set. In such case we need to add | |
| 3355 | // to the current function's inferred error set, if any. | |
| 3356 | if ((sema.typeOf(operand).zigTypeTag() == .ErrorUnion or | |
| 3357 | sema.typeOf(operand).zigTypeTag() == .ErrorSet) and | |
| 3357 | 3358 | sema.fn_ret_ty.zigTypeTag() == .ErrorUnion) |
| 3358 | 3359 | { |
| 3359 | 3360 | if (Zir.refToIndex(extra.lhs)) |ptr_index| { |
| ... | ... | @@ -7665,6 +7666,8 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7665 | 7666 | const container_type = try sema.resolveType(block, lhs_src, extra.lhs); |
| 7666 | 7667 | const decl_name = try sema.resolveConstString(block, rhs_src, extra.rhs); |
| 7667 | 7668 | |
| 7669 | // tuples are structs but they don't have a namespace | |
| 7670 | if (container_type.isTuple()) return Air.Inst.Ref.bool_false; | |
| 7668 | 7671 | const namespace = container_type.getNamespace() orelse return sema.fail( |
| 7669 | 7672 | block, |
| 7670 | 7673 | lhs_src, |
| ... | ... | @@ -12186,7 +12189,7 @@ fn checkPtrOperand( |
| 12186 | 12189 | ty: Type, |
| 12187 | 12190 | ) CompileError!void { |
| 12188 | 12191 | switch (ty.zigTypeTag()) { |
| 12189 | .Pointer => {}, | |
| 12192 | .Pointer => return, | |
| 12190 | 12193 | .Fn => { |
| 12191 | 12194 | const msg = msg: { |
| 12192 | 12195 | const msg = try sema.errMsg( |
| ... | ... | @@ -12203,8 +12206,10 @@ fn checkPtrOperand( |
| 12203 | 12206 | }; |
| 12204 | 12207 | return sema.failWithOwnedErrorMsg(msg); |
| 12205 | 12208 | }, |
| 12206 | else => return sema.fail(block, ty_src, "expected pointer, found '{}'", .{ty}), | |
| 12209 | .Optional => if (ty.isPtrLikeOptional()) return, | |
| 12210 | else => {}, | |
| 12207 | 12211 | } |
| 12212 | return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty}); | |
| 12208 | 12213 | } |
| 12209 | 12214 | |
| 12210 | 12215 | fn checkPtrType( |
| ... | ... | @@ -12214,7 +12219,7 @@ fn checkPtrType( |
| 12214 | 12219 | ty: Type, |
| 12215 | 12220 | ) CompileError!void { |
| 12216 | 12221 | switch (ty.zigTypeTag()) { |
| 12217 | .Pointer => {}, | |
| 12222 | .Pointer => return, | |
| 12218 | 12223 | .Fn => { |
| 12219 | 12224 | const msg = msg: { |
| 12220 | 12225 | const msg = try sema.errMsg( |
| ... | ... | @@ -12231,8 +12236,10 @@ fn checkPtrType( |
| 12231 | 12236 | }; |
| 12232 | 12237 | return sema.failWithOwnedErrorMsg(msg); |
| 12233 | 12238 | }, |
| 12234 | else => return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty}), | |
| 12239 | .Optional => if (ty.isPtrLikeOptional()) return, | |
| 12240 | else => {}, | |
| 12235 | 12241 | } |
| 12242 | return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty}); | |
| 12236 | 12243 | } |
| 12237 | 12244 | |
| 12238 | 12245 | fn checkVectorElemType( |
src/type.zig+4-2| ... | ... | @@ -593,10 +593,12 @@ pub const Type = extern union { |
| 593 | 593 | |
| 594 | 594 | for (a_info.param_types) |a_param_ty, i| { |
| 595 | 595 | const b_param_ty = b_info.param_types[i]; |
| 596 | if (!eql(a_param_ty, b_param_ty)) | |
| 596 | if (a_info.comptime_params[i] != b_info.comptime_params[i]) | |
| 597 | 597 | return false; |
| 598 | 598 | |
| 599 | if (a_info.comptime_params[i] != b_info.comptime_params[i]) | |
| 599 | if (a_param_ty.tag() == .generic_poison) continue; | |
| 600 | if (b_param_ty.tag() == .generic_poison) continue; | |
| 601 | if (!eql(a_param_ty, b_param_ty)) | |
| 600 | 602 | return false; |
| 601 | 603 | } |
| 602 | 604 |
test/behavior.zig+9-9| ... | ... | @@ -120,6 +120,15 @@ test { |
| 120 | 120 | _ = @import("behavior/sizeof_and_typeof.zig"); |
| 121 | 121 | _ = @import("behavior/switch.zig"); |
| 122 | 122 | _ = @import("behavior/widening.zig"); |
| 123 | _ = @import("behavior/bugs/421.zig"); | |
| 124 | _ = @import("behavior/bugs/726.zig"); | |
| 125 | _ = @import("behavior/bugs/1421.zig"); | |
| 126 | _ = @import("behavior/bugs/2114.zig"); | |
| 127 | _ = @import("behavior/bugs/3742.zig"); | |
| 128 | _ = @import("behavior/struct_contains_null_ptr_itself.zig"); | |
| 129 | _ = @import("behavior/switch_prong_err_enum.zig"); | |
| 130 | _ = @import("behavior/switch_prong_implicit_cast.zig"); | |
| 131 | _ = @import("behavior/union_with_members.zig"); | |
| 123 | 132 | |
| 124 | 133 | if (builtin.zig_backend == .stage1) { |
| 125 | 134 | // Tests that only pass for the stage1 backend. |
| ... | ... | @@ -128,20 +137,15 @@ test { |
| 128 | 137 | _ = @import("behavior/async_fn.zig"); |
| 129 | 138 | } |
| 130 | 139 | _ = @import("behavior/await_struct.zig"); |
| 131 | _ = @import("behavior/bugs/421.zig"); | |
| 132 | 140 | _ = @import("behavior/bugs/529.zig"); |
| 133 | 141 | _ = @import("behavior/bugs/718.zig"); |
| 134 | _ = @import("behavior/bugs/726.zig"); | |
| 135 | 142 | _ = @import("behavior/bugs/828.zig"); |
| 136 | 143 | _ = @import("behavior/bugs/920.zig"); |
| 137 | 144 | _ = @import("behavior/bugs/1120.zig"); |
| 138 | _ = @import("behavior/bugs/1421.zig"); | |
| 139 | 145 | _ = @import("behavior/bugs/1442.zig"); |
| 140 | 146 | _ = @import("behavior/bugs/1607.zig"); |
| 141 | 147 | _ = @import("behavior/bugs/1851.zig"); |
| 142 | _ = @import("behavior/bugs/2114.zig"); | |
| 143 | 148 | _ = @import("behavior/bugs/3384.zig"); |
| 144 | _ = @import("behavior/bugs/3742.zig"); | |
| 145 | 149 | _ = @import("behavior/bugs/3779.zig"); |
| 146 | 150 | _ = @import("behavior/bugs/4328.zig"); |
| 147 | 151 | _ = @import("behavior/bugs/5398.zig"); |
| ... | ... | @@ -161,12 +165,8 @@ test { |
| 161 | 165 | _ = @import("behavior/muladd.zig"); |
| 162 | 166 | _ = @import("behavior/select.zig"); |
| 163 | 167 | _ = @import("behavior/shuffle.zig"); |
| 164 | _ = @import("behavior/struct_contains_null_ptr_itself.zig"); | |
| 165 | 168 | _ = @import("behavior/struct_contains_slice_of_itself.zig"); |
| 166 | _ = @import("behavior/switch_prong_err_enum.zig"); | |
| 167 | _ = @import("behavior/switch_prong_implicit_cast.zig"); | |
| 168 | 169 | _ = @import("behavior/typename.zig"); |
| 169 | _ = @import("behavior/union_with_members.zig"); | |
| 170 | 170 | _ = @import("behavior/vector.zig"); |
| 171 | 171 | if (builtin.target.cpu.arch == .wasm32) { |
| 172 | 172 | _ = @import("behavior/wasm.zig"); |
test/behavior/type_info.zig+4| ... | ... | @@ -323,6 +323,10 @@ fn testOpaque() !void { |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | test "type info: function type info" { |
| 326 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 327 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 328 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 329 | ||
| 326 | 330 | // wasm doesn't support align attributes on functions |
| 327 | 331 | if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest; |
| 328 | 332 | try testFunction(); |