| author | |
| committer | |
| log | 1951051e3d692d8257e46fc23a7dff9447828fd7 |
| tree | 24d1e8ec92fcc47c7774a6ed35b3e228796d1158 |
| parent | 77a334451f1329110d6c1bd07b46813cef10e97c |
| parent | 4cde6dd10902ebeec3b3000b76d6395c49f5a241 |
| signature |
Move passing stage1 compile error tests to stage2734 files changed, 4879 insertions(+), 4675 deletions(-)
src/AstGen.zig+11-4| ... | ... | @@ -1476,7 +1476,7 @@ fn arrayInitExprRlPtr( |
| 1476 | 1476 | return arrayInitExprRlPtrInner(gz, scope, node, base_ptr, elements); |
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr); | |
| 1479 | var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr, node); | |
| 1480 | 1480 | defer as_scope.unstack(); |
| 1481 | 1481 | |
| 1482 | 1482 | const result = try arrayInitExprRlPtrInner(&as_scope, scope, node, as_scope.rl_ptr, elements); |
| ... | ... | @@ -1697,7 +1697,7 @@ fn structInitExprRlPtr( |
| 1697 | 1697 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1698 | 1698 | _ = try gz.addUnNode(.validate_struct_init_ty, ty_inst, node); |
| 1699 | 1699 | |
| 1700 | var as_scope = try gz.makeCoercionScope(scope, ty_inst, result_ptr); | |
| 1700 | var as_scope = try gz.makeCoercionScope(scope, ty_inst, result_ptr, node); | |
| 1701 | 1701 | defer as_scope.unstack(); |
| 1702 | 1702 | |
| 1703 | 1703 | const result = try structInitExprRlPtrInner(&as_scope, scope, node, struct_init, as_scope.rl_ptr); |
| ... | ... | @@ -4464,6 +4464,7 @@ fn containerDecl( |
| 4464 | 4464 | var total_fields: usize = 0; |
| 4465 | 4465 | var decls: usize = 0; |
| 4466 | 4466 | var nonexhaustive_node: Ast.Node.Index = 0; |
| 4467 | var nonfinal_nonexhaustive = false; | |
| 4467 | 4468 | for (container_decl.ast.members) |member_node| { |
| 4468 | 4469 | const member = switch (node_tags[member_node]) { |
| 4469 | 4470 | .container_field_init => tree.containerFieldInit(member_node), |
| ... | ... | @@ -4515,6 +4516,8 @@ fn containerDecl( |
| 4515 | 4516 | return astgen.failNode(member.ast.value_expr, "'_' is used to mark an enum as non-exhaustive and cannot be assigned a value", .{}); |
| 4516 | 4517 | } |
| 4517 | 4518 | continue; |
| 4519 | } else if (nonexhaustive_node != 0) { | |
| 4520 | nonfinal_nonexhaustive = true; | |
| 4518 | 4521 | } |
| 4519 | 4522 | total_fields += 1; |
| 4520 | 4523 | if (member.ast.value_expr != 0) { |
| ... | ... | @@ -4524,6 +4527,9 @@ fn containerDecl( |
| 4524 | 4527 | values += 1; |
| 4525 | 4528 | } |
| 4526 | 4529 | } |
| 4530 | if (nonfinal_nonexhaustive) { | |
| 4531 | return astgen.failNode(nonexhaustive_node, "'_' field of non-exhaustive enum must be last", .{}); | |
| 4532 | } | |
| 4527 | 4533 | break :blk .{ |
| 4528 | 4534 | .total_fields = total_fields, |
| 4529 | 4535 | .values = values, |
| ... | ... | @@ -7040,7 +7046,7 @@ fn asRlPtr( |
| 7040 | 7046 | operand_node: Ast.Node.Index, |
| 7041 | 7047 | dest_type: Zir.Inst.Ref, |
| 7042 | 7048 | ) InnerError!Zir.Inst.Ref { |
| 7043 | var as_scope = try parent_gz.makeCoercionScope(scope, dest_type, result_ptr); | |
| 7049 | var as_scope = try parent_gz.makeCoercionScope(scope, dest_type, result_ptr, src_node); | |
| 7044 | 7050 | defer as_scope.unstack(); |
| 7045 | 7051 | |
| 7046 | 7052 | const result = try reachableExpr(&as_scope, &as_scope.base, .{ .block_ptr = &as_scope }, operand_node, src_node); |
| ... | ... | @@ -9897,13 +9903,14 @@ const GenZir = struct { |
| 9897 | 9903 | scope: *Scope, |
| 9898 | 9904 | dest_type: Zir.Inst.Ref, |
| 9899 | 9905 | result_ptr: Zir.Inst.Ref, |
| 9906 | src_node: Ast.Node.Index, | |
| 9900 | 9907 | ) !GenZir { |
| 9901 | 9908 | // Detect whether this expr() call goes into rvalue() to store the result into the |
| 9902 | 9909 | // result location. If it does, elide the coerce_result_ptr instruction |
| 9903 | 9910 | // as well as the store instruction, instead passing the result as an rvalue. |
| 9904 | 9911 | var as_scope = parent_gz.makeSubBlock(scope); |
| 9905 | 9912 | errdefer as_scope.unstack(); |
| 9906 | as_scope.rl_ptr = try as_scope.addBin(.coerce_result_ptr, dest_type, result_ptr); | |
| 9913 | as_scope.rl_ptr = try as_scope.addPlNode(.coerce_result_ptr, src_node, Zir.Inst.Bin{ .lhs = dest_type, .rhs = result_ptr }); | |
| 9907 | 9914 | |
| 9908 | 9915 | // `rl_ty_inst` needs to be set in case the stores to `rl_ptr` are eliminated. |
| 9909 | 9916 | as_scope.rl_ty_inst = dest_type; |
src/Module.zig+5| ... | ... | @@ -503,6 +503,8 @@ pub const Decl = struct { |
| 503 | 503 | alive: bool, |
| 504 | 504 | /// Whether the Decl is a `usingnamespace` declaration. |
| 505 | 505 | is_usingnamespace: bool, |
| 506 | /// If true `name` is already fully qualified. | |
| 507 | name_fully_qualified: bool = false, | |
| 506 | 508 | |
| 507 | 509 | /// Represents the position of the code in the output file. |
| 508 | 510 | /// This is populated regardless of semantic analysis and code generation. |
| ... | ... | @@ -686,6 +688,9 @@ pub const Decl = struct { |
| 686 | 688 | |
| 687 | 689 | pub fn renderFullyQualifiedName(decl: Decl, mod: *Module, writer: anytype) !void { |
| 688 | 690 | const unqualified_name = mem.sliceTo(decl.name, 0); |
| 691 | if (decl.name_fully_qualified) { | |
| 692 | return writer.writeAll(unqualified_name); | |
| 693 | } | |
| 689 | 694 | return decl.src_namespace.renderFullyQualifiedName(mod, unqualified_name, writer); |
| 690 | 695 | } |
| 691 | 696 |
src/Sema.zig+314-124| ... | ... | @@ -139,6 +139,7 @@ pub const Block = struct { |
| 139 | 139 | |
| 140 | 140 | is_comptime: bool, |
| 141 | 141 | is_typeof: bool = false, |
| 142 | is_coerce_result_ptr: bool = false, | |
| 142 | 143 | |
| 143 | 144 | /// when null, it is determined by build mode, changed by @setRuntimeSafety |
| 144 | 145 | want_safety: ?bool = null, |
| ... | ... | @@ -1707,7 +1708,7 @@ fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: T |
| 1707 | 1708 | } |
| 1708 | 1709 | |
| 1709 | 1710 | fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, optional_ty: Type) CompileError { |
| 1710 | return sema.fail(block, src, "expected optional type, found {}", .{optional_ty.fmt(sema.mod)}); | |
| 1711 | return sema.fail(block, src, "expected optional type, found '{}'", .{optional_ty.fmt(sema.mod)}); | |
| 1711 | 1712 | } |
| 1712 | 1713 | |
| 1713 | 1714 | fn failWithArrayInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError { |
| ... | ... | @@ -1734,9 +1735,20 @@ fn failWithErrorSetCodeMissing( |
| 1734 | 1735 | }); |
| 1735 | 1736 | } |
| 1736 | 1737 | |
| 1737 | fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value) CompileError { | |
| 1738 | fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value, vector_index: usize) CompileError { | |
| 1739 | if (int_ty.zigTypeTag() == .Vector) { | |
| 1740 | const msg = msg: { | |
| 1741 | const msg = try sema.errMsg(block, src, "overflow of vector type '{}' with value '{}'", .{ | |
| 1742 | int_ty.fmt(sema.mod), val.fmtValue(int_ty, sema.mod), | |
| 1743 | }); | |
| 1744 | errdefer msg.destroy(sema.gpa); | |
| 1745 | try sema.errNote(block, src, msg, "when computing vector element at index '{d}'", .{vector_index}); | |
| 1746 | break :msg msg; | |
| 1747 | }; | |
| 1748 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 1749 | } | |
| 1738 | 1750 | return sema.fail(block, src, "overflow of integer type '{}' with value '{}'", .{ |
| 1739 | int_ty.fmt(sema.mod), val.fmtValue(Type.@"comptime_int", sema.mod), | |
| 1751 | int_ty.fmt(sema.mod), val.fmtValue(int_ty, sema.mod), | |
| 1740 | 1752 | }); |
| 1741 | 1753 | } |
| 1742 | 1754 | |
| ... | ... | @@ -1844,7 +1856,7 @@ pub fn resolveAlign( |
| 1844 | 1856 | const alignment = @intCast(u32, alignment_big); // We coerce to u16 in the prev line. |
| 1845 | 1857 | if (alignment == 0) return sema.fail(block, src, "alignment must be >= 1", .{}); |
| 1846 | 1858 | if (!std.math.isPowerOfTwo(alignment)) { |
| 1847 | return sema.fail(block, src, "alignment value {d} is not a power of two", .{ | |
| 1859 | return sema.fail(block, src, "alignment value '{d}' is not a power of two", .{ | |
| 1848 | 1860 | alignment, |
| 1849 | 1861 | }); |
| 1850 | 1862 | } |
| ... | ... | @@ -1901,10 +1913,11 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 1901 | 1913 | const tracy = trace(@src()); |
| 1902 | 1914 | defer tracy.end(); |
| 1903 | 1915 | |
| 1904 | const src: LazySrcLoc = sema.src; | |
| 1905 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | |
| 1906 | const pointee_ty = try sema.resolveType(block, src, bin_inst.lhs); | |
| 1907 | const ptr = try sema.resolveInst(bin_inst.rhs); | |
| 1916 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | |
| 1917 | const src = inst_data.src(); | |
| 1918 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | |
| 1919 | const pointee_ty = try sema.resolveType(block, src, extra.lhs); | |
| 1920 | const ptr = try sema.resolveInst(extra.rhs); | |
| 1908 | 1921 | const target = sema.mod.getTarget(); |
| 1909 | 1922 | const addr_space = target_util.defaultAddressSpace(target, .local); |
| 1910 | 1923 | |
| ... | ... | @@ -1971,6 +1984,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 1971 | 1984 | // kind of transformations to make on the result pointer. |
| 1972 | 1985 | var trash_block = block.makeSubBlock(); |
| 1973 | 1986 | trash_block.is_comptime = false; |
| 1987 | trash_block.is_coerce_result_ptr = true; | |
| 1974 | 1988 | defer trash_block.instructions.deinit(sema.gpa); |
| 1975 | 1989 | |
| 1976 | 1990 | const dummy_ptr = try trash_block.addTy(.alloc, sema.typeOf(ptr)); |
| ... | ... | @@ -2376,6 +2390,12 @@ fn zirEnumDecl( |
| 2376 | 2390 | } |
| 2377 | 2391 | } |
| 2378 | 2392 | |
| 2393 | if (small.nonexhaustive) { | |
| 2394 | if (fields_len > 1 and std.math.log2_int(u64, fields_len) == enum_obj.tag_ty.bitSize(sema.mod.getTarget())) { | |
| 2395 | return sema.fail(block, src, "non-exhaustive enum specifies every value", .{}); | |
| 2396 | } | |
| 2397 | } | |
| 2398 | ||
| 2379 | 2399 | try enum_obj.fields.ensureTotalCapacity(new_decl_arena_allocator, fields_len); |
| 2380 | 2400 | const any_values = for (sema.code.extra[body_end..][0..bit_bags_count]) |bag| { |
| 2381 | 2401 | if (bag != 0) break true; |
| ... | ... | @@ -4540,6 +4560,7 @@ fn analyzeBlockBody( |
| 4540 | 4560 | // to emit a jump instruction to after the block when it encounters the break. |
| 4541 | 4561 | try parent_block.instructions.append(gpa, merges.block_inst); |
| 4542 | 4562 | const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items, .none); |
| 4563 | // TODO add note "missing else causes void value" | |
| 4543 | 4564 | |
| 4544 | 4565 | const type_src = src; // TODO: better source location |
| 4545 | 4566 | const valid_rt = try sema.validateRunTimeType(child_block, type_src, resolved_ty, false); |
| ... | ... | @@ -4761,7 +4782,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst |
| 4761 | 4782 | const msg = msg: { |
| 4762 | 4783 | const msg = try sema.errMsg(block, src, "multiple @setAlignStack in the same function body", .{}); |
| 4763 | 4784 | errdefer msg.destroy(sema.gpa); |
| 4764 | try sema.errNote(block, src, msg, "other instance here", .{}); | |
| 4785 | try sema.errNote(block, gop.value_ptr.src, msg, "other instance here", .{}); | |
| 4765 | 4786 | break :msg msg; |
| 4766 | 4787 | }; |
| 4767 | 4788 | return sema.failWithOwnedErrorMsg(block, msg); |
| ... | ... | @@ -5224,6 +5245,10 @@ fn analyzeCall( |
| 5224 | 5245 | .async_kw => return sema.fail(block, call_src, "TODO implement async call", .{}), |
| 5225 | 5246 | }; |
| 5226 | 5247 | |
| 5248 | if (modifier == .never_inline and func_ty_info.cc == .Inline) { | |
| 5249 | return sema.fail(block, call_src, "no-inline call of inline function", .{}); | |
| 5250 | } | |
| 5251 | ||
| 5227 | 5252 | const gpa = sema.gpa; |
| 5228 | 5253 | |
| 5229 | 5254 | var is_generic_call = func_ty_info.is_generic; |
| ... | ... | @@ -5263,6 +5288,10 @@ fn analyzeCall( |
| 5263 | 5288 | } |
| 5264 | 5289 | } |
| 5265 | 5290 | |
| 5291 | if (is_comptime_call and modifier == .never_inline) { | |
| 5292 | return sema.fail(block, call_src, "unable to perform 'never_inline' call at compile-time", .{}); | |
| 5293 | } | |
| 5294 | ||
| 5266 | 5295 | const result: Air.Inst.Ref = if (is_inline_call) res: { |
| 5267 | 5296 | const func_val = try sema.resolveConstValue(block, func_src, func); |
| 5268 | 5297 | const module_fn = switch (func_val.tag()) { |
| ... | ... | @@ -6155,7 +6184,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 6155 | 6184 | const payload = try sema.resolveType(block, rhs_src, extra.rhs); |
| 6156 | 6185 | |
| 6157 | 6186 | if (error_set.zigTypeTag() != .ErrorSet) { |
| 6158 | return sema.fail(block, lhs_src, "expected error set type, found {}", .{ | |
| 6187 | return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{ | |
| 6159 | 6188 | error_set.fmt(sema.mod), |
| 6160 | 6189 | }); |
| 6161 | 6190 | } |
| ... | ... | @@ -6243,7 +6272,7 @@ fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 6243 | 6272 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |value| { |
| 6244 | 6273 | const int = try sema.usizeCast(block, operand_src, value.toUnsignedInt(target)); |
| 6245 | 6274 | if (int > sema.mod.global_error_set.count() or int == 0) |
| 6246 | return sema.fail(block, operand_src, "integer value {d} represents no error", .{int}); | |
| 6275 | return sema.fail(block, operand_src, "integer value '{d}' represents no error", .{int}); | |
| 6247 | 6276 | const payload = try sema.arena.create(Value.Payload.Error); |
| 6248 | 6277 | payload.* = .{ |
| 6249 | 6278 | .base = .{ .tag = .@"error" }, |
| ... | ... | @@ -6288,9 +6317,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 6288 | 6317 | const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs); |
| 6289 | 6318 | const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs); |
| 6290 | 6319 | if (lhs_ty.zigTypeTag() != .ErrorSet) |
| 6291 | return sema.fail(block, lhs_src, "expected error set type, found {}", .{lhs_ty.fmt(sema.mod)}); | |
| 6320 | return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{lhs_ty.fmt(sema.mod)}); | |
| 6292 | 6321 | if (rhs_ty.zigTypeTag() != .ErrorSet) |
| 6293 | return sema.fail(block, rhs_src, "expected error set type, found {}", .{rhs_ty.fmt(sema.mod)}); | |
| 6322 | return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(sema.mod)}); | |
| 6294 | 6323 | |
| 6295 | 6324 | // Anything merged with anyerror is anyerror. |
| 6296 | 6325 | if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) { |
| ... | ... | @@ -6351,7 +6380,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 6351 | 6380 | break :blk try sema.unionToTag(block, tag_ty, operand, operand_src); |
| 6352 | 6381 | }, |
| 6353 | 6382 | else => { |
| 6354 | return sema.fail(block, operand_src, "expected enum or tagged union, found {}", .{ | |
| 6383 | return sema.fail(block, operand_src, "expected enum or tagged union, found '{}'", .{ | |
| 6355 | 6384 | operand_ty.fmt(sema.mod), |
| 6356 | 6385 | }); |
| 6357 | 6386 | }, |
| ... | ... | @@ -6385,7 +6414,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 6385 | 6414 | const operand = try sema.resolveInst(extra.rhs); |
| 6386 | 6415 | |
| 6387 | 6416 | if (dest_ty.zigTypeTag() != .Enum) { |
| 6388 | return sema.fail(block, dest_ty_src, "expected enum, found {}", .{dest_ty.fmt(sema.mod)}); | |
| 6417 | return sema.fail(block, dest_ty_src, "expected enum, found '{}'", .{dest_ty.fmt(sema.mod)}); | |
| 6389 | 6418 | } |
| 6390 | 6419 | |
| 6391 | 6420 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |int_val| { |
| ... | ... | @@ -6400,7 +6429,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 6400 | 6429 | const msg = try sema.errMsg( |
| 6401 | 6430 | block, |
| 6402 | 6431 | src, |
| 6403 | "enum '{}' has no tag with value {}", | |
| 6432 | "enum '{}' has no tag with value '{}'", | |
| 6404 | 6433 | .{ dest_ty.fmt(sema.mod), int_val.fmtValue(sema.typeOf(operand), sema.mod) }, |
| 6405 | 6434 | ); |
| 6406 | 6435 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -6452,7 +6481,7 @@ fn analyzeOptionalPayloadPtr( |
| 6452 | 6481 | |
| 6453 | 6482 | const opt_type = optional_ptr_ty.elemType(); |
| 6454 | 6483 | if (opt_type.zigTypeTag() != .Optional) { |
| 6455 | return sema.fail(block, src, "expected optional type, found {}", .{opt_type.fmt(sema.mod)}); | |
| 6484 | return sema.fail(block, src, "expected optional type, found '{}'", .{opt_type.fmt(sema.mod)}); | |
| 6456 | 6485 | } |
| 6457 | 6486 | |
| 6458 | 6487 | const child_type = try opt_type.optionalChildAlloc(sema.arena); |
| ... | ... | @@ -6640,7 +6669,7 @@ fn analyzeErrUnionPayloadPtr( |
| 6640 | 6669 | assert(operand_ty.zigTypeTag() == .Pointer); |
| 6641 | 6670 | |
| 6642 | 6671 | if (operand_ty.elemType().zigTypeTag() != .ErrorUnion) { |
| 6643 | return sema.fail(block, src, "expected error union type, found {}", .{ | |
| 6672 | return sema.fail(block, src, "expected error union type, found '{}'", .{ | |
| 6644 | 6673 | operand_ty.elemType().fmt(sema.mod), |
| 6645 | 6674 | }); |
| 6646 | 6675 | } |
| ... | ... | @@ -6739,7 +6768,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 6739 | 6768 | assert(operand_ty.zigTypeTag() == .Pointer); |
| 6740 | 6769 | |
| 6741 | 6770 | if (operand_ty.elemType().zigTypeTag() != .ErrorUnion) { |
| 6742 | return sema.fail(block, src, "expected error union type, found {}", .{ | |
| 6771 | return sema.fail(block, src, "expected error union type, found '{}'", .{ | |
| 6743 | 6772 | operand_ty.elemType().fmt(sema.mod), |
| 6744 | 6773 | }); |
| 6745 | 6774 | } |
| ... | ... | @@ -7639,7 +7668,6 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 7639 | 7668 | defer tracy.end(); |
| 7640 | 7669 | |
| 7641 | 7670 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7642 | const src = inst_data.src(); | |
| 7643 | 7671 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 7644 | 7672 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 7645 | 7673 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| ... | ... | @@ -7674,7 +7702,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 7674 | 7702 | return sema.addConstant(dest_ty, try operand_val.floatCast(sema.arena, dest_ty, target)); |
| 7675 | 7703 | } |
| 7676 | 7704 | if (dest_is_comptime_float) { |
| 7677 | return sema.fail(block, src, "unable to cast runtime value to 'comptime_float'", .{}); | |
| 7705 | return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_float'", .{}); | |
| 7678 | 7706 | } |
| 7679 | 7707 | const src_bits = operand_ty.floatBits(target); |
| 7680 | 7708 | const dst_bits = dest_ty.floatBits(target); |
| ... | ... | @@ -9000,6 +9028,10 @@ fn validateSwitchRange( |
| 9000 | 9028 | ) CompileError!void { |
| 9001 | 9029 | const first_val = (try sema.resolveSwitchItemVal(block, first_ref, src_node_offset, switch_prong_src, .first)).val; |
| 9002 | 9030 | const last_val = (try sema.resolveSwitchItemVal(block, last_ref, src_node_offset, switch_prong_src, .last)).val; |
| 9031 | if (first_val.compare(.gt, last_val, operand_ty, sema.mod)) { | |
| 9032 | const src = switch_prong_src.resolve(sema.gpa, sema.mod.declPtr(block.src_decl), src_node_offset, .first); | |
| 9033 | return sema.fail(block, src, "range start value is greater than the end value", .{}); | |
| 9034 | } | |
| 9003 | 9035 | const maybe_prev_src = try range_set.add(first_val, last_val, operand_ty, switch_prong_src); |
| 9004 | 9036 | return sema.validateSwitchDupe(block, maybe_prev_src, switch_prong_src, src_node_offset); |
| 9005 | 9037 | } |
| ... | ... | @@ -9347,9 +9379,34 @@ fn zirShl( |
| 9347 | 9379 | if (rhs_val.isUndef()) { |
| 9348 | 9380 | return sema.addConstUndef(sema.typeOf(lhs)); |
| 9349 | 9381 | } |
| 9382 | // If rhs is 0, return lhs without doing any calculations. | |
| 9350 | 9383 | if (try rhs_val.compareWithZeroAdvanced(.eq, sema.kit(block, src))) { |
| 9351 | 9384 | return lhs; |
| 9352 | 9385 | } |
| 9386 | if (scalar_ty.zigTypeTag() != .ComptimeInt and air_tag != .shl_sat) { | |
| 9387 | var bits_payload = Value.Payload.U64{ | |
| 9388 | .base = .{ .tag = .int_u64 }, | |
| 9389 | .data = scalar_ty.intInfo(target).bits, | |
| 9390 | }; | |
| 9391 | const bit_value = Value.initPayload(&bits_payload.base); | |
| 9392 | if (rhs_ty.zigTypeTag() == .Vector) { | |
| 9393 | var i: usize = 0; | |
| 9394 | while (i < rhs_ty.vectorLen()) : (i += 1) { | |
| 9395 | if (rhs_val.indexVectorlike(i).compareHetero(.gte, bit_value, target)) { | |
| 9396 | return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ | |
| 9397 | rhs_val.indexVectorlike(i).fmtValue(scalar_ty, sema.mod), | |
| 9398 | i, | |
| 9399 | scalar_ty.fmt(sema.mod), | |
| 9400 | }); | |
| 9401 | } | |
| 9402 | } | |
| 9403 | } else if (rhs_val.compareHetero(.gte, bit_value, target)) { | |
| 9404 | return sema.fail(block, rhs_src, "shift amount '{}' is too large for operand type '{}'", .{ | |
| 9405 | rhs_val.fmtValue(scalar_ty, sema.mod), | |
| 9406 | scalar_ty.fmt(sema.mod), | |
| 9407 | }); | |
| 9408 | } | |
| 9409 | } | |
| 9353 | 9410 | } |
| 9354 | 9411 | |
| 9355 | 9412 | const runtime_src = if (maybe_lhs_val) |lhs_val| rs: { |
| ... | ... | @@ -9461,16 +9518,44 @@ fn zirShr( |
| 9461 | 9518 | const rhs_ty = sema.typeOf(rhs); |
| 9462 | 9519 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 9463 | 9520 | const target = sema.mod.getTarget(); |
| 9521 | const scalar_ty = lhs_ty.scalarType(); | |
| 9464 | 9522 | |
| 9465 | 9523 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, rhs_src, rhs)) |rhs_val| rs: { |
| 9524 | if (rhs_val.isUndef()) { | |
| 9525 | return sema.addConstUndef(lhs_ty); | |
| 9526 | } | |
| 9527 | // If rhs is 0, return lhs without doing any calculations. | |
| 9528 | if (try rhs_val.compareWithZeroAdvanced(.eq, sema.kit(block, src))) { | |
| 9529 | return lhs; | |
| 9530 | } | |
| 9531 | if (scalar_ty.zigTypeTag() != .ComptimeInt) { | |
| 9532 | var bits_payload = Value.Payload.U64{ | |
| 9533 | .base = .{ .tag = .int_u64 }, | |
| 9534 | .data = scalar_ty.intInfo(target).bits, | |
| 9535 | }; | |
| 9536 | const bit_value = Value.initPayload(&bits_payload.base); | |
| 9537 | if (rhs_ty.zigTypeTag() == .Vector) { | |
| 9538 | var i: usize = 0; | |
| 9539 | while (i < rhs_ty.vectorLen()) : (i += 1) { | |
| 9540 | if (rhs_val.indexVectorlike(i).compareHetero(.gte, bit_value, target)) { | |
| 9541 | return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ | |
| 9542 | rhs_val.indexVectorlike(i).fmtValue(scalar_ty, sema.mod), | |
| 9543 | i, | |
| 9544 | scalar_ty.fmt(sema.mod), | |
| 9545 | }); | |
| 9546 | } | |
| 9547 | } | |
| 9548 | } else if (rhs_val.compareHetero(.gte, bit_value, target)) { | |
| 9549 | return sema.fail(block, rhs_src, "shift amount '{}' is too large for operand type '{}'", .{ | |
| 9550 | rhs_val.fmtValue(scalar_ty, sema.mod), | |
| 9551 | scalar_ty.fmt(sema.mod), | |
| 9552 | }); | |
| 9553 | } | |
| 9554 | } | |
| 9466 | 9555 | if (try sema.resolveMaybeUndefVal(block, lhs_src, lhs)) |lhs_val| { |
| 9467 | if (lhs_val.isUndef() or rhs_val.isUndef()) { | |
| 9556 | if (lhs_val.isUndef()) { | |
| 9468 | 9557 | return sema.addConstUndef(lhs_ty); |
| 9469 | 9558 | } |
| 9470 | // If rhs is 0, return lhs without doing any calculations. | |
| 9471 | if (try rhs_val.compareWithZeroAdvanced(.eq, sema.kit(block, src))) { | |
| 9472 | return sema.addConstant(lhs_ty, lhs_val); | |
| 9473 | } | |
| 9474 | 9559 | if (air_tag == .shr_exact) { |
| 9475 | 9560 | // Detect if any ones would be shifted out. |
| 9476 | 9561 | const truncated = try lhs_val.intTruncBitsAsValue(lhs_ty, sema.arena, .unsigned, rhs_val, target); |
| ... | ... | @@ -9481,12 +9566,6 @@ fn zirShr( |
| 9481 | 9566 | const val = try lhs_val.shr(rhs_val, lhs_ty, sema.arena, target); |
| 9482 | 9567 | return sema.addConstant(lhs_ty, val); |
| 9483 | 9568 | } else { |
| 9484 | // Even if lhs is not comptime known, we can still deduce certain things based | |
| 9485 | // on rhs. | |
| 9486 | // If rhs is 0, return lhs without doing any calculations. | |
| 9487 | if (try rhs_val.compareWithZeroAdvanced(.eq, sema.kit(block, src))) { | |
| 9488 | return lhs; | |
| 9489 | } | |
| 9490 | 9569 | break :rs lhs_src; |
| 9491 | 9570 | } |
| 9492 | 9571 | } else rhs_src; |
| ... | ... | @@ -10065,7 +10144,10 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 10065 | 10144 | const rhs_ty = sema.typeOf(rhs); |
| 10066 | 10145 | const rhs_scalar_ty = rhs_ty.scalarType(); |
| 10067 | 10146 | |
| 10068 | if (rhs_scalar_ty.isUnsignedInt()) { | |
| 10147 | if (rhs_scalar_ty.isUnsignedInt() or switch (rhs_scalar_ty.zigTypeTag()) { | |
| 10148 | .Int, .ComptimeInt, .Float, .ComptimeFloat => false, | |
| 10149 | else => true, | |
| 10150 | }) { | |
| 10069 | 10151 | return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(sema.mod)}); |
| 10070 | 10152 | } |
| 10071 | 10153 | |
| ... | ... | @@ -10096,6 +10178,12 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10096 | 10178 | |
| 10097 | 10179 | const rhs = try sema.resolveInst(inst_data.operand); |
| 10098 | 10180 | const rhs_ty = sema.typeOf(rhs); |
| 10181 | const rhs_scalar_ty = rhs_ty.scalarType(); | |
| 10182 | ||
| 10183 | switch (rhs_scalar_ty.zigTypeTag()) { | |
| 10184 | .Int, .ComptimeInt, .Float, .ComptimeFloat => {}, | |
| 10185 | else => return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(sema.mod)}), | |
| 10186 | } | |
| 10099 | 10187 | |
| 10100 | 10188 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) |
| 10101 | 10189 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) |
| ... | ... | @@ -10441,8 +10529,9 @@ fn analyzeArithmetic( |
| 10441 | 10529 | if (maybe_rhs_val) |rhs_val| { |
| 10442 | 10530 | if (is_int) { |
| 10443 | 10531 | const sum = try sema.intAdd(block, src, lhs_val, rhs_val, resolved_type); |
| 10444 | if (!(try sema.intFitsInType(block, src, sum, resolved_type))) { | |
| 10445 | return sema.failWithIntegerOverflow(block, src, resolved_type, sum); | |
| 10532 | var vector_index: usize = undefined; | |
| 10533 | if (!(try sema.intFitsInType(block, src, sum, resolved_type, &vector_index))) { | |
| 10534 | return sema.failWithIntegerOverflow(block, src, resolved_type, sum, vector_index); | |
| 10446 | 10535 | } |
| 10447 | 10536 | return sema.addConstant(resolved_type, sum); |
| 10448 | 10537 | } else { |
| ... | ... | @@ -10535,8 +10624,9 @@ fn analyzeArithmetic( |
| 10535 | 10624 | if (maybe_rhs_val) |rhs_val| { |
| 10536 | 10625 | if (is_int) { |
| 10537 | 10626 | const diff = try sema.intSub(block, src, lhs_val, rhs_val, resolved_type); |
| 10538 | if (!(try sema.intFitsInType(block, src, diff, resolved_type))) { | |
| 10539 | return sema.failWithIntegerOverflow(block, src, resolved_type, diff); | |
| 10627 | var vector_index: usize = undefined; | |
| 10628 | if (!(try sema.intFitsInType(block, src, diff, resolved_type, &vector_index))) { | |
| 10629 | return sema.failWithIntegerOverflow(block, src, resolved_type, diff, vector_index); | |
| 10540 | 10630 | } |
| 10541 | 10631 | return sema.addConstant(resolved_type, diff); |
| 10542 | 10632 | } else { |
| ... | ... | @@ -10909,8 +10999,9 @@ fn analyzeArithmetic( |
| 10909 | 10999 | } |
| 10910 | 11000 | if (is_int) { |
| 10911 | 11001 | const product = try lhs_val.intMul(rhs_val, resolved_type, sema.arena, target); |
| 10912 | if (!(try sema.intFitsInType(block, src, product, resolved_type))) { | |
| 10913 | return sema.failWithIntegerOverflow(block, src, resolved_type, product); | |
| 11002 | var vector_index: usize = undefined; | |
| 11003 | if (!(try sema.intFitsInType(block, src, product, resolved_type, &vector_index))) { | |
| 11004 | return sema.failWithIntegerOverflow(block, src, resolved_type, product, vector_index); | |
| 10914 | 11005 | } |
| 10915 | 11006 | return sema.addConstant(resolved_type, product); |
| 10916 | 11007 | } else { |
| ... | ... | @@ -11608,8 +11699,13 @@ fn analyzeCmpUnionTag( |
| 11608 | 11699 | ) CompileError!Air.Inst.Ref { |
| 11609 | 11700 | const union_ty = try sema.resolveTypeFields(block, un_src, sema.typeOf(un)); |
| 11610 | 11701 | const union_tag_ty = union_ty.unionTagType() orelse { |
| 11611 | // TODO note at declaration site that says "union foo is not tagged" | |
| 11612 | return sema.fail(block, un_src, "comparison of union and enum literal is only valid for tagged union types", .{}); | |
| 11702 | const msg = msg: { | |
| 11703 | const msg = try sema.errMsg(block, un_src, "comparison of union and enum literal is only valid for tagged union types", .{}); | |
| 11704 | errdefer msg.destroy(sema.gpa); | |
| 11705 | try sema.mod.errNoteNonLazy(union_ty.declSrcLoc(sema.mod), msg, "union '{}' is not a tagged union", .{union_ty.fmt(sema.mod)}); | |
| 11706 | break :msg msg; | |
| 11707 | }; | |
| 11708 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 11613 | 11709 | }; |
| 11614 | 11710 | // Coerce both the union and the tag to the union's tag type, and then execute the |
| 11615 | 11711 | // enum comparison codepath. |
| ... | ... | @@ -11666,8 +11762,8 @@ fn analyzeCmp( |
| 11666 | 11762 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 11667 | 11763 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ .override = &[_]LazySrcLoc{ lhs_src, rhs_src } }); |
| 11668 | 11764 | if (!resolved_type.isSelfComparable(is_equality_cmp)) { |
| 11669 | return sema.fail(block, src, "{s} operator not allowed for type '{}'", .{ | |
| 11670 | @tagName(op), resolved_type.fmt(sema.mod), | |
| 11765 | return sema.fail(block, src, "operator {s} not allowed for type '{}'", .{ | |
| 11766 | compareOperatorName(op), resolved_type.fmt(sema.mod), | |
| 11671 | 11767 | }); |
| 11672 | 11768 | } |
| 11673 | 11769 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| ... | ... | @@ -11675,6 +11771,17 @@ fn analyzeCmp( |
| 11675 | 11771 | return sema.cmpSelf(block, casted_lhs, casted_rhs, op, lhs_src, rhs_src); |
| 11676 | 11772 | } |
| 11677 | 11773 | |
| 11774 | fn compareOperatorName(comp: std.math.CompareOperator) []const u8 { | |
| 11775 | return switch (comp) { | |
| 11776 | .lt => "<", | |
| 11777 | .lte => "<=", | |
| 11778 | .eq => "==", | |
| 11779 | .gte => ">=", | |
| 11780 | .gt => ">", | |
| 11781 | .neq => "!=", | |
| 11782 | }; | |
| 11783 | } | |
| 11784 | ||
| 11678 | 11785 | fn cmpSelf( |
| 11679 | 11786 | sema: *Sema, |
| 11680 | 11787 | block: *Block, |
| ... | ... | @@ -13098,7 +13205,6 @@ fn zirCondbr( |
| 13098 | 13205 | defer tracy.end(); |
| 13099 | 13206 | |
| 13100 | 13207 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 13101 | const src = inst_data.src(); | |
| 13102 | 13208 | const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node }; |
| 13103 | 13209 | const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index); |
| 13104 | 13210 | |
| ... | ... | @@ -13108,7 +13214,7 @@ fn zirCondbr( |
| 13108 | 13214 | const uncasted_cond = try sema.resolveInst(extra.data.condition); |
| 13109 | 13215 | const cond = try sema.coerce(parent_block, Type.bool, uncasted_cond, cond_src); |
| 13110 | 13216 | |
| 13111 | if (try sema.resolveDefinedValue(parent_block, src, cond)) |cond_val| { | |
| 13217 | if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| { | |
| 13112 | 13218 | const body = if (cond_val.toBool()) then_body else else_body; |
| 13113 | 13219 | // We use `analyzeBodyInner` since we want to propagate any possible |
| 13114 | 13220 | // `error.ComptimeBreak` to the caller. |
| ... | ... | @@ -14384,7 +14490,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 14384 | 14490 | }; |
| 14385 | 14491 | return sema.failWithOwnedErrorMsg(block, msg); |
| 14386 | 14492 | }, |
| 14387 | else => return sema.fail(block, operand_src, "expected enum or union; found {}", .{ | |
| 14493 | else => return sema.fail(block, operand_src, "expected enum or union; found '{}'", .{ | |
| 14388 | 14494 | operand_ty.fmt(mod), |
| 14389 | 14495 | }), |
| 14390 | 14496 | }; |
| ... | ... | @@ -14394,8 +14500,8 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 14394 | 14500 | const field_index = enum_ty.enumTagFieldIndex(val, mod) orelse { |
| 14395 | 14501 | const enum_decl = mod.declPtr(enum_decl_index); |
| 14396 | 14502 | const msg = msg: { |
| 14397 | const msg = try sema.errMsg(block, src, "no field with value {} in enum '{s}'", .{ | |
| 14398 | casted_operand, enum_decl.name, | |
| 14503 | const msg = try sema.errMsg(block, src, "no field with value '{}' in enum '{s}'", .{ | |
| 14504 | val.fmtValue(enum_ty, sema.mod), enum_decl.name, | |
| 14399 | 14505 | }); |
| 14400 | 14506 | errdefer msg.destroy(sema.gpa); |
| 14401 | 14507 | try mod.errNoteNonLazy(enum_decl.srcLoc(), msg, "declared here", .{}); |
| ... | ... | @@ -14460,6 +14566,8 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 14460 | 14566 | var buffer: Value.ToTypeBuffer = undefined; |
| 14461 | 14567 | const child_ty = child_val.toType(&buffer); |
| 14462 | 14568 | |
| 14569 | try sema.checkVectorElemType(block, src, child_ty); | |
| 14570 | ||
| 14463 | 14571 | const ty = try Type.vector(sema.arena, len, try child_ty.copy(sema.arena)); |
| 14464 | 14572 | return sema.addType(ty); |
| 14465 | 14573 | }, |
| ... | ... | @@ -14837,7 +14945,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 14837 | 14945 | union_obj.tag_ty = if (tag_type_val.optionalValue()) |payload_val| blk: { |
| 14838 | 14946 | var buffer: Value.ToTypeBuffer = undefined; |
| 14839 | 14947 | break :blk try payload_val.toType(&buffer).copy(new_decl_arena_allocator); |
| 14840 | } else try sema.generateUnionTagTypeSimple(block, fields_len); | |
| 14948 | } else try sema.generateUnionTagTypeSimple(block, fields_len, null); | |
| 14841 | 14949 | |
| 14842 | 14950 | // Fields |
| 14843 | 14951 | if (fields_len > 0) { |
| ... | ... | @@ -15101,6 +15209,8 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 15101 | 15209 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| 15102 | 15210 | const result_val = try sema.floatToInt(block, operand_src, val, operand_ty, dest_ty); |
| 15103 | 15211 | return sema.addConstant(dest_ty, result_val); |
| 15212 | } else if (dest_ty.zigTypeTag() == .ComptimeInt) { | |
| 15213 | return sema.failWithNeededComptime(block, operand_src); | |
| 15104 | 15214 | } |
| 15105 | 15215 | |
| 15106 | 15216 | try sema.requireRuntimeBlock(block, operand_src); |
| ... | ... | @@ -15123,6 +15233,8 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 15123 | 15233 | const target = sema.mod.getTarget(); |
| 15124 | 15234 | const result_val = try val.intToFloat(sema.arena, operand_ty, dest_ty, target); |
| 15125 | 15235 | return sema.addConstant(dest_ty, result_val); |
| 15236 | } else if (dest_ty.zigTypeTag() == .ComptimeFloat) { | |
| 15237 | return sema.failWithNeededComptime(block, operand_src); | |
| 15126 | 15238 | } |
| 15127 | 15239 | |
| 15128 | 15240 | try sema.requireRuntimeBlock(block, operand_src); |
| ... | ... | @@ -15244,7 +15356,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 15244 | 15356 | const msg = try sema.errMsg( |
| 15245 | 15357 | block, |
| 15246 | 15358 | src, |
| 15247 | "error.{s} not a member of error set '{}'", | |
| 15359 | "'error.{s}' not a member of error set '{}'", | |
| 15248 | 15360 | .{ error_name, dest_ty.fmt(sema.mod) }, |
| 15249 | 15361 | ); |
| 15250 | 15362 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -15635,22 +15747,29 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 15635 | 15747 | |
| 15636 | 15748 | try sema.resolveTypeLayout(block, lhs_src, ty); |
| 15637 | 15749 | if (ty.tag() != .@"struct") { |
| 15638 | return sema.fail( | |
| 15639 | block, | |
| 15640 | lhs_src, | |
| 15641 | "expected struct type, found '{}'", | |
| 15642 | .{ty.fmt(sema.mod)}, | |
| 15643 | ); | |
| 15750 | const msg = msg: { | |
| 15751 | const msg = try sema.errMsg(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(sema.mod)}); | |
| 15752 | errdefer msg.destroy(sema.gpa); | |
| 15753 | try sema.addDeclaredHereNote(msg, ty); | |
| 15754 | break :msg msg; | |
| 15755 | }; | |
| 15756 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 15644 | 15757 | } |
| 15645 | 15758 | |
| 15646 | 15759 | const fields = ty.structFields(); |
| 15647 | 15760 | const index = fields.getIndex(field_name) orelse { |
| 15648 | return sema.fail( | |
| 15649 | block, | |
| 15650 | rhs_src, | |
| 15651 | "struct '{}' has no field '{s}'", | |
| 15652 | .{ ty.fmt(sema.mod), field_name }, | |
| 15653 | ); | |
| 15761 | const msg = msg: { | |
| 15762 | const msg = try sema.errMsg( | |
| 15763 | block, | |
| 15764 | rhs_src, | |
| 15765 | "struct '{}' has no field '{s}'", | |
| 15766 | .{ ty.fmt(sema.mod), field_name }, | |
| 15767 | ); | |
| 15768 | errdefer msg.destroy(sema.gpa); | |
| 15769 | try sema.addDeclaredHereNote(msg, ty); | |
| 15770 | break :msg msg; | |
| 15771 | }; | |
| 15772 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 15654 | 15773 | }; |
| 15655 | 15774 | |
| 15656 | 15775 | switch (ty.containerLayout()) { |
| ... | ... | @@ -15703,7 +15822,7 @@ fn checkPtrOperand( |
| 15703 | 15822 | const msg = try sema.errMsg( |
| 15704 | 15823 | block, |
| 15705 | 15824 | ty_src, |
| 15706 | "expected pointer, found {}", | |
| 15825 | "expected pointer, found '{}'", | |
| 15707 | 15826 | .{ty.fmt(sema.mod)}, |
| 15708 | 15827 | ); |
| 15709 | 15828 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -15819,7 +15938,7 @@ fn checkAtomicPtrOperand( |
| 15819 | 15938 | error.BadType => return sema.fail( |
| 15820 | 15939 | block, |
| 15821 | 15940 | elem_ty_src, |
| 15822 | "expected bool, integer, float, enum, or pointer type; found {}", | |
| 15941 | "expected bool, integer, float, enum, or pointer type; found '{}'", | |
| 15823 | 15942 | .{elem_ty.fmt(sema.mod)}, |
| 15824 | 15943 | ), |
| 15825 | 15944 | }; |
| ... | ... | @@ -16028,7 +16147,7 @@ fn checkVectorizableBinaryOperands( |
| 16028 | 16147 | } |
| 16029 | 16148 | } else { |
| 16030 | 16149 | const msg = msg: { |
| 16031 | const msg = try sema.errMsg(block, src, "mixed scalar and vector operands: {} and {}", .{ | |
| 16150 | const msg = try sema.errMsg(block, src, "mixed scalar and vector operands: '{}' and '{}'", .{ | |
| 16032 | 16151 | lhs_ty.fmt(sema.mod), rhs_ty.fmt(sema.mod), |
| 16033 | 16152 | }); |
| 16034 | 16153 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -16071,6 +16190,10 @@ fn resolveExportOptions( |
| 16071 | 16190 | const visibility_val = try sema.resolveConstValue(block, src, visibility_operand); |
| 16072 | 16191 | const visibility = visibility_val.toEnum(std.builtin.SymbolVisibility); |
| 16073 | 16192 | |
| 16193 | if (name.len < 1) { | |
| 16194 | return sema.fail(block, src, "exported symbol name cannot be empty", .{}); | |
| 16195 | } | |
| 16196 | ||
| 16074 | 16197 | if (visibility != .default and linkage == .Internal) { |
| 16075 | 16198 | return sema.fail(block, src, "symbol '{s}' exported with internal linkage has non-default visibility {s}", .{ |
| 16076 | 16199 | name, @tagName(visibility), |
| ... | ... | @@ -16249,7 +16372,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 16249 | 16372 | const target = sema.mod.getTarget(); |
| 16250 | 16373 | |
| 16251 | 16374 | if (operand_ty.zigTypeTag() != .Vector) { |
| 16252 | return sema.fail(block, operand_src, "expected vector, found {}", .{operand_ty.fmt(sema.mod)}); | |
| 16375 | return sema.fail(block, operand_src, "expected vector, found '{}'", .{operand_ty.fmt(sema.mod)}); | |
| 16253 | 16376 | } |
| 16254 | 16377 | |
| 16255 | 16378 | const scalar_ty = operand_ty.childType(); |
| ... | ... | @@ -16258,13 +16381,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 16258 | 16381 | switch (operation) { |
| 16259 | 16382 | .And, .Or, .Xor => switch (scalar_ty.zigTypeTag()) { |
| 16260 | 16383 | .Int, .Bool => {}, |
| 16261 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found {}", .{ | |
| 16384 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{}'", .{ | |
| 16262 | 16385 | @tagName(operation), operand_ty.fmt(sema.mod), |
| 16263 | 16386 | }), |
| 16264 | 16387 | }, |
| 16265 | 16388 | .Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag()) { |
| 16266 | 16389 | .Int, .Float => {}, |
| 16267 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found {}", .{ | |
| 16390 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{}'", .{ | |
| 16268 | 16391 | @tagName(operation), operand_ty.fmt(sema.mod), |
| 16269 | 16392 | }), |
| 16270 | 16393 | }, |
| ... | ... | @@ -16323,7 +16446,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 16323 | 16446 | |
| 16324 | 16447 | const mask_len = switch (sema.typeOf(mask).zigTypeTag()) { |
| 16325 | 16448 | .Array, .Vector => sema.typeOf(mask).arrayLen(), |
| 16326 | else => return sema.fail(block, mask_src, "expected vector or array, found {}", .{sema.typeOf(mask).fmt(sema.mod)}), | |
| 16449 | else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(sema.mod)}), | |
| 16327 | 16450 | }; |
| 16328 | 16451 | mask_ty = try Type.Tag.vector.create(sema.arena, .{ |
| 16329 | 16452 | .len = mask_len, |
| ... | ... | @@ -16358,7 +16481,7 @@ fn analyzeShuffle( |
| 16358 | 16481 | var maybe_a_len = switch (sema.typeOf(a).zigTypeTag()) { |
| 16359 | 16482 | .Array, .Vector => sema.typeOf(a).arrayLen(), |
| 16360 | 16483 | .Undefined => null, |
| 16361 | else => return sema.fail(block, a_src, "expected vector or array with element type {}, found {}", .{ | |
| 16484 | else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{ | |
| 16362 | 16485 | elem_ty.fmt(sema.mod), |
| 16363 | 16486 | sema.typeOf(a).fmt(sema.mod), |
| 16364 | 16487 | }), |
| ... | ... | @@ -16366,7 +16489,7 @@ fn analyzeShuffle( |
| 16366 | 16489 | var maybe_b_len = switch (sema.typeOf(b).zigTypeTag()) { |
| 16367 | 16490 | .Array, .Vector => sema.typeOf(b).arrayLen(), |
| 16368 | 16491 | .Undefined => null, |
| 16369 | else => return sema.fail(block, b_src, "expected vector or array with element type {}, found {}", .{ | |
| 16492 | else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{ | |
| 16370 | 16493 | elem_ty.fmt(sema.mod), |
| 16371 | 16494 | sema.typeOf(b).fmt(sema.mod), |
| 16372 | 16495 | }), |
| ... | ... | @@ -16411,15 +16534,15 @@ fn analyzeShuffle( |
| 16411 | 16534 | } |
| 16412 | 16535 | if (unsigned >= operand_info[chosen][0]) { |
| 16413 | 16536 | const msg = msg: { |
| 16414 | const msg = try sema.errMsg(block, mask_src, "mask index {d} has out-of-bounds selection", .{i}); | |
| 16537 | const msg = try sema.errMsg(block, mask_src, "mask index '{d}' has out-of-bounds selection", .{i}); | |
| 16415 | 16538 | errdefer msg.destroy(sema.gpa); |
| 16416 | 16539 | |
| 16417 | try sema.errNote(block, operand_info[chosen][1], msg, "selected index {d} out of bounds of {}", .{ | |
| 16540 | try sema.errNote(block, operand_info[chosen][1], msg, "selected index '{d}' out of bounds of '{}'", .{ | |
| 16418 | 16541 | unsigned, |
| 16419 | 16542 | operand_info[chosen][2].fmt(sema.mod), |
| 16420 | 16543 | }); |
| 16421 | 16544 | |
| 16422 | if (chosen == 1) { | |
| 16545 | if (chosen == 0) { | |
| 16423 | 16546 | try sema.errNote(block, b_src, msg, "selections from the second vector are specified with negative numbers", .{}); |
| 16424 | 16547 | } |
| 16425 | 16548 | |
| ... | ... | @@ -16846,10 +16969,15 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16846 | 16969 | break :modifier modifier_val.toEnum(std.builtin.CallOptions.Modifier); |
| 16847 | 16970 | }; |
| 16848 | 16971 | |
| 16972 | const is_comptime = extra.flags.is_comptime or block.is_comptime; | |
| 16973 | ||
| 16849 | 16974 | const modifier: std.builtin.CallOptions.Modifier = switch (wanted_modifier) { |
| 16850 | 16975 | // These can be upgraded to comptime or nosuspend calls. |
| 16851 | 16976 | .auto, .never_tail, .no_async => m: { |
| 16852 | if (extra.flags.is_comptime) { | |
| 16977 | if (is_comptime) { | |
| 16978 | if (wanted_modifier == .never_tail) { | |
| 16979 | return sema.fail(block, options_src, "unable to perform 'never_tail' call at compile-time", .{}); | |
| 16980 | } | |
| 16853 | 16981 | break :m .compile_time; |
| 16854 | 16982 | } |
| 16855 | 16983 | if (extra.flags.is_nosuspend) { |
| ... | ... | @@ -16859,7 +16987,11 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16859 | 16987 | }, |
| 16860 | 16988 | // These can be upgraded to comptime. nosuspend bit can be safely ignored. |
| 16861 | 16989 | .always_tail, .always_inline, .compile_time => m: { |
| 16862 | if (extra.flags.is_comptime) { | |
| 16990 | _ = (try sema.resolveDefinedValue(block, func_src, func)) orelse { | |
| 16991 | return sema.fail(block, func_src, "modifier '{s}' requires a comptime-known function", .{@tagName(wanted_modifier)}); | |
| 16992 | }; | |
| 16993 | ||
| 16994 | if (is_comptime) { | |
| 16863 | 16995 | break :m .compile_time; |
| 16864 | 16996 | } |
| 16865 | 16997 | break :m wanted_modifier; |
| ... | ... | @@ -16868,14 +17000,14 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16868 | 17000 | if (extra.flags.is_nosuspend) { |
| 16869 | 17001 | return sema.fail(block, options_src, "modifier 'async_kw' cannot be used inside nosuspend block", .{}); |
| 16870 | 17002 | } |
| 16871 | if (extra.flags.is_comptime) { | |
| 17003 | if (is_comptime) { | |
| 16872 | 17004 | return sema.fail(block, options_src, "modifier 'async_kw' cannot be used in combination with comptime function call", .{}); |
| 16873 | 17005 | } |
| 16874 | 17006 | break :m wanted_modifier; |
| 16875 | 17007 | }, |
| 16876 | 17008 | .never_inline => m: { |
| 16877 | if (extra.flags.is_comptime) { | |
| 16878 | return sema.fail(block, options_src, "modifier 'never_inline' cannot be used in combination with comptime function call", .{}); | |
| 17009 | if (is_comptime) { | |
| 17010 | return sema.fail(block, options_src, "unable to perform 'never_inline' call at compile-time", .{}); | |
| 16879 | 17011 | } |
| 16880 | 17012 | break :m wanted_modifier; |
| 16881 | 17013 | }, |
| ... | ... | @@ -16883,7 +17015,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16883 | 17015 | |
| 16884 | 17016 | const args_ty = sema.typeOf(args); |
| 16885 | 17017 | if (!args_ty.isTuple() and args_ty.tag() != .empty_struct_literal) { |
| 16886 | return sema.fail(block, args_src, "expected a tuple, found {}", .{args_ty.fmt(sema.mod)}); | |
| 17018 | return sema.fail(block, args_src, "expected a tuple, found '{}'", .{args_ty.fmt(sema.mod)}); | |
| 16887 | 17019 | } |
| 16888 | 17020 | |
| 16889 | 17021 | var resolved_args: []Air.Inst.Ref = undefined; |
| ... | ... | @@ -17696,7 +17828,7 @@ fn zirBuiltinExtern( |
| 17696 | 17828 | } |
| 17697 | 17829 | |
| 17698 | 17830 | fn requireFunctionBlock(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 17699 | if (sema.func == null and !block.is_typeof) { | |
| 17831 | if (sema.func == null and !block.is_typeof and !block.is_coerce_result_ptr) { | |
| 17700 | 17832 | return sema.fail(block, src, "instruction illegal outside function body", .{}); |
| 17701 | 17833 | } |
| 17702 | 17834 | } |
| ... | ... | @@ -17765,7 +17897,8 @@ fn validateRunTimeType( |
| 17765 | 17897 | .Pointer => { |
| 17766 | 17898 | const elem_ty = ty.childType(); |
| 17767 | 17899 | switch (elem_ty.zigTypeTag()) { |
| 17768 | .Opaque, .Fn => return true, | |
| 17900 | .Opaque => return true, | |
| 17901 | .Fn => return elem_ty.isFnOrHasRuntimeBits(), | |
| 17769 | 17902 | else => ty = elem_ty, |
| 17770 | 17903 | } |
| 17771 | 17904 | }, |
| ... | ... | @@ -17829,7 +17962,25 @@ fn explainWhyTypeIsComptime( |
| 17829 | 17962 | .Optional, |
| 17830 | 17963 | => return, |
| 17831 | 17964 | |
| 17832 | .Pointer, .Array, .Vector => { | |
| 17965 | .Array, .Vector => { | |
| 17966 | try sema.explainWhyTypeIsComptime(block, src, msg, src_loc, ty.elemType()); | |
| 17967 | }, | |
| 17968 | .Pointer => { | |
| 17969 | const elem_ty = ty.elemType2(); | |
| 17970 | if (elem_ty.zigTypeTag() == .Fn) { | |
| 17971 | const fn_info = elem_ty.fnInfo(); | |
| 17972 | if (fn_info.is_generic) { | |
| 17973 | try mod.errNoteNonLazy(src_loc, msg, "function is generic", .{}); | |
| 17974 | } | |
| 17975 | switch (fn_info.cc) { | |
| 17976 | .Inline => try mod.errNoteNonLazy(src_loc, msg, "function has inline calling convention", .{}), | |
| 17977 | else => {}, | |
| 17978 | } | |
| 17979 | if (fn_info.return_type.comptimeOnly()) { | |
| 17980 | try mod.errNoteNonLazy(src_loc, msg, "function has a comptime-only return type", .{}); | |
| 17981 | } | |
| 17982 | return; | |
| 17983 | } | |
| 17833 | 17984 | try sema.explainWhyTypeIsComptime(block, src, msg, src_loc, ty.elemType()); |
| 17834 | 17985 | }, |
| 17835 | 17986 | |
| ... | ... | @@ -18219,9 +18370,15 @@ fn fieldVal( |
| 18219 | 18370 | if (payload.data.names.getEntry(field_name)) |entry| { |
| 18220 | 18371 | break :blk entry.key_ptr.*; |
| 18221 | 18372 | } |
| 18222 | return sema.fail(block, src, "no error named '{s}' in '{}'", .{ | |
| 18223 | field_name, child_type.fmt(sema.mod), | |
| 18224 | }); | |
| 18373 | const msg = msg: { | |
| 18374 | const msg = try sema.errMsg(block, src, "no error named '{s}' in '{}'", .{ | |
| 18375 | field_name, child_type.fmt(sema.mod), | |
| 18376 | }); | |
| 18377 | errdefer msg.destroy(sema.gpa); | |
| 18378 | try sema.addDeclaredHereNote(msg, child_type); | |
| 18379 | break :msg msg; | |
| 18380 | }; | |
| 18381 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 18225 | 18382 | } else (try sema.mod.getErrorValue(field_name)).key; |
| 18226 | 18383 | |
| 18227 | 18384 | return sema.addConstant( |
| ... | ... | @@ -18896,12 +19053,12 @@ fn tupleFieldIndex( |
| 18896 | 19053 | field_name_src: LazySrcLoc, |
| 18897 | 19054 | ) CompileError!u32 { |
| 18898 | 19055 | const field_index = std.fmt.parseUnsigned(u32, field_name, 10) catch |err| { |
| 18899 | return sema.fail(block, field_name_src, "tuple {} has no such field '{s}': {s}", .{ | |
| 19056 | return sema.fail(block, field_name_src, "tuple '{}' has no such field '{s}': {s}", .{ | |
| 18900 | 19057 | tuple_ty.fmt(sema.mod), field_name, @errorName(err), |
| 18901 | 19058 | }); |
| 18902 | 19059 | }; |
| 18903 | 19060 | if (field_index >= tuple_ty.structFieldCount()) { |
| 18904 | return sema.fail(block, field_name_src, "tuple {} has no such field '{s}'", .{ | |
| 19061 | return sema.fail(block, field_name_src, "tuple '{}' has no such field '{s}'", .{ | |
| 18905 | 19062 | tuple_ty.fmt(sema.mod), field_name, |
| 18906 | 19063 | }); |
| 18907 | 19064 | } |
| ... | ... | @@ -19811,7 +19968,7 @@ fn coerce( |
| 19811 | 19968 | return sema.fail( |
| 19812 | 19969 | block, |
| 19813 | 19970 | inst_src, |
| 19814 | "fractional component prevents float value {} from coercion to type '{}'", | |
| 19971 | "fractional component prevents float value '{}' from coercion to type '{}'", | |
| 19815 | 19972 | .{ val.fmtValue(inst_ty, sema.mod), dest_ty.fmt(sema.mod) }, |
| 19816 | 19973 | ); |
| 19817 | 19974 | } |
| ... | ... | @@ -19821,8 +19978,8 @@ fn coerce( |
| 19821 | 19978 | .Int, .ComptimeInt => { |
| 19822 | 19979 | if (try sema.resolveDefinedValue(block, inst_src, inst)) |val| { |
| 19823 | 19980 | // comptime known integer to other number |
| 19824 | if (!(try sema.intFitsInType(block, inst_src, val, dest_ty))) { | |
| 19825 | return sema.fail(block, inst_src, "type {} cannot represent integer value {}", .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) }); | |
| 19981 | if (!(try sema.intFitsInType(block, inst_src, val, dest_ty, null))) { | |
| 19982 | return sema.fail(block, inst_src, "type '{}' cannot represent integer value '{}'", .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) }); | |
| 19826 | 19983 | } |
| 19827 | 19984 | return try sema.addConstant(dest_ty, val); |
| 19828 | 19985 | } |
| ... | ... | @@ -19856,7 +20013,7 @@ fn coerce( |
| 19856 | 20013 | return sema.fail( |
| 19857 | 20014 | block, |
| 19858 | 20015 | inst_src, |
| 19859 | "type {} cannot represent float value {}", | |
| 20016 | "type '{}' cannot represent float value '{}'", | |
| 19860 | 20017 | .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) }, |
| 19861 | 20018 | ); |
| 19862 | 20019 | } |
| ... | ... | @@ -19880,7 +20037,7 @@ fn coerce( |
| 19880 | 20037 | // return sema.fail( |
| 19881 | 20038 | // block, |
| 19882 | 20039 | // inst_src, |
| 19883 | // "type {} cannot represent integer value {}", | |
| 20040 | // "type '{}' cannot represent integer value '{}'", | |
| 19884 | 20041 | // .{ dest_ty.fmt(sema.mod), val }, |
| 19885 | 20042 | // ); |
| 19886 | 20043 | //} |
| ... | ... | @@ -20023,7 +20180,7 @@ fn coerce( |
| 20023 | 20180 | return sema.addConstUndef(dest_ty); |
| 20024 | 20181 | } |
| 20025 | 20182 | |
| 20026 | return sema.fail(block, inst_src, "expected {}, found {}", .{ dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod) }); | |
| 20183 | return sema.fail(block, inst_src, "expected type '{}', found '{}'", .{ dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod) }); | |
| 20027 | 20184 | } |
| 20028 | 20185 | |
| 20029 | 20186 | const InMemoryCoercionResult = enum { |
| ... | ... | @@ -21543,7 +21700,7 @@ fn coerceEnumToUnion( |
| 21543 | 21700 | |
| 21544 | 21701 | const tag_ty = union_ty.unionTagType() orelse { |
| 21545 | 21702 | const msg = msg: { |
| 21546 | const msg = try sema.errMsg(block, inst_src, "expected {}, found {}", .{ | |
| 21703 | const msg = try sema.errMsg(block, inst_src, "expected type '{}', found '{}'", .{ | |
| 21547 | 21704 | union_ty.fmt(sema.mod), inst_ty.fmt(sema.mod), |
| 21548 | 21705 | }); |
| 21549 | 21706 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -21559,7 +21716,7 @@ fn coerceEnumToUnion( |
| 21559 | 21716 | const union_obj = union_ty.cast(Type.Payload.Union).?.data; |
| 21560 | 21717 | const field_index = union_obj.tag_ty.enumTagFieldIndex(val, sema.mod) orelse { |
| 21561 | 21718 | const msg = msg: { |
| 21562 | const msg = try sema.errMsg(block, inst_src, "union {} has no tag with value {}", .{ | |
| 21719 | const msg = try sema.errMsg(block, inst_src, "union '{}' has no tag with value '{}'", .{ | |
| 21563 | 21720 | union_ty.fmt(sema.mod), val.fmtValue(tag_ty, sema.mod), |
| 21564 | 21721 | }); |
| 21565 | 21722 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -21595,7 +21752,7 @@ fn coerceEnumToUnion( |
| 21595 | 21752 | |
| 21596 | 21753 | if (tag_ty.isNonexhaustiveEnum()) { |
| 21597 | 21754 | const msg = msg: { |
| 21598 | const msg = try sema.errMsg(block, inst_src, "runtime coercion to union {} from non-exhaustive enum", .{ | |
| 21755 | const msg = try sema.errMsg(block, inst_src, "runtime coercion to union '{}' from non-exhaustive enum", .{ | |
| 21599 | 21756 | union_ty.fmt(sema.mod), |
| 21600 | 21757 | }); |
| 21601 | 21758 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -21712,7 +21869,7 @@ fn coerceArrayLike( |
| 21712 | 21869 | |
| 21713 | 21870 | if (dest_len != inst_len) { |
| 21714 | 21871 | const msg = msg: { |
| 21715 | const msg = try sema.errMsg(block, inst_src, "expected {}, found {}", .{ | |
| 21872 | const msg = try sema.errMsg(block, inst_src, "expected type '{}', found '{}'", .{ | |
| 21716 | 21873 | dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod), |
| 21717 | 21874 | }); |
| 21718 | 21875 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -21783,7 +21940,7 @@ fn coerceTupleToArray( |
| 21783 | 21940 | |
| 21784 | 21941 | if (dest_len != inst_len) { |
| 21785 | 21942 | const msg = msg: { |
| 21786 | const msg = try sema.errMsg(block, inst_src, "expected {}, found {}", .{ | |
| 21943 | const msg = try sema.errMsg(block, inst_src, "expected type '{}', found '{}'", .{ | |
| 21787 | 21944 | dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod), |
| 21788 | 21945 | }); |
| 21789 | 21946 | errdefer msg.destroy(sema.gpa); |
| ... | ... | @@ -23555,7 +23712,7 @@ fn resolveStructLayout( |
| 23555 | 23712 | switch (struct_obj.status) { |
| 23556 | 23713 | .none, .have_field_types => {}, |
| 23557 | 23714 | .field_types_wip, .layout_wip => { |
| 23558 | return sema.fail(block, src, "struct {} depends on itself", .{ty.fmt(sema.mod)}); | |
| 23715 | return sema.fail(block, src, "struct '{}' depends on itself", .{ty.fmt(sema.mod)}); | |
| 23559 | 23716 | }, |
| 23560 | 23717 | .have_layout, .fully_resolved_wip, .fully_resolved => return, |
| 23561 | 23718 | } |
| ... | ... | @@ -23586,7 +23743,7 @@ fn resolveUnionLayout( |
| 23586 | 23743 | switch (union_obj.status) { |
| 23587 | 23744 | .none, .have_field_types => {}, |
| 23588 | 23745 | .field_types_wip, .layout_wip => { |
| 23589 | return sema.fail(block, src, "union {} depends on itself", .{ty.fmt(sema.mod)}); | |
| 23746 | return sema.fail(block, src, "union '{}' depends on itself", .{ty.fmt(sema.mod)}); | |
| 23590 | 23747 | }, |
| 23591 | 23748 | .have_layout, .fully_resolved_wip, .fully_resolved => return, |
| 23592 | 23749 | } |
| ... | ... | @@ -23754,7 +23911,7 @@ fn resolveTypeFieldsStruct( |
| 23754 | 23911 | switch (struct_obj.status) { |
| 23755 | 23912 | .none => {}, |
| 23756 | 23913 | .field_types_wip => { |
| 23757 | return sema.fail(block, src, "struct {} depends on itself", .{ty.fmt(sema.mod)}); | |
| 23914 | return sema.fail(block, src, "struct '{}' depends on itself", .{ty.fmt(sema.mod)}); | |
| 23758 | 23915 | }, |
| 23759 | 23916 | .have_field_types, |
| 23760 | 23917 | .have_layout, |
| ... | ... | @@ -23784,7 +23941,7 @@ fn resolveTypeFieldsUnion( |
| 23784 | 23941 | switch (union_obj.status) { |
| 23785 | 23942 | .none => {}, |
| 23786 | 23943 | .field_types_wip => { |
| 23787 | return sema.fail(block, src, "union {} depends on itself", .{ty.fmt(sema.mod)}); | |
| 23944 | return sema.fail(block, src, "union '{}' depends on itself", .{ty.fmt(sema.mod)}); | |
| 23788 | 23945 | }, |
| 23789 | 23946 | .have_field_types, |
| 23790 | 23947 | .have_layout, |
| ... | ... | @@ -24161,7 +24318,7 @@ fn semaUnionFields(block: *Block, mod: *Module, union_obj: *Module.Union) Compil |
| 24161 | 24318 | if (small.auto_enum_tag) { |
| 24162 | 24319 | // The provided type is an integer type and we must construct the enum tag type here. |
| 24163 | 24320 | int_tag_ty = provided_ty; |
| 24164 | union_obj.tag_ty = try sema.generateUnionTagTypeNumbered(&block_scope, fields_len, provided_ty); | |
| 24321 | union_obj.tag_ty = try sema.generateUnionTagTypeNumbered(&block_scope, fields_len, provided_ty, union_obj); | |
| 24165 | 24322 | const enum_obj = union_obj.tag_ty.castTag(.enum_numbered).?.data; |
| 24166 | 24323 | enum_field_names = &enum_obj.fields; |
| 24167 | 24324 | enum_value_map = &enum_obj.values; |
| ... | ... | @@ -24177,7 +24334,7 @@ fn semaUnionFields(block: *Block, mod: *Module, union_obj: *Module.Union) Compil |
| 24177 | 24334 | // If auto_enum_tag is false, this is an untagged union. However, for semantic analysis |
| 24178 | 24335 | // purposes, we still auto-generate an enum tag type the same way. That the union is |
| 24179 | 24336 | // untagged is represented by the Type tag (union vs union_tagged). |
| 24180 | union_obj.tag_ty = try sema.generateUnionTagTypeSimple(&block_scope, fields_len); | |
| 24337 | union_obj.tag_ty = try sema.generateUnionTagTypeSimple(&block_scope, fields_len, union_obj); | |
| 24181 | 24338 | enum_field_names = &union_obj.tag_ty.castTag(.enum_simple).?.data.fields; |
| 24182 | 24339 | } |
| 24183 | 24340 | |
| ... | ... | @@ -24346,6 +24503,7 @@ fn generateUnionTagTypeNumbered( |
| 24346 | 24503 | block: *Block, |
| 24347 | 24504 | fields_len: u32, |
| 24348 | 24505 | int_ty: Type, |
| 24506 | union_obj: *Module.Union, | |
| 24349 | 24507 | ) !Type { |
| 24350 | 24508 | const mod = sema.mod; |
| 24351 | 24509 | |
| ... | ... | @@ -24361,13 +24519,24 @@ fn generateUnionTagTypeNumbered( |
| 24361 | 24519 | }; |
| 24362 | 24520 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 24363 | 24521 | const enum_val = try Value.Tag.ty.create(new_decl_arena_allocator, enum_ty); |
| 24364 | // TODO better type name | |
| 24365 | const new_decl_index = try mod.createAnonymousDecl(block, .{ | |
| 24522 | ||
| 24523 | const src_decl = mod.declPtr(block.src_decl); | |
| 24524 | const new_decl_index = try mod.allocateNewDecl(block.namespace, src_decl.src_node, block.wip_capture_scope); | |
| 24525 | errdefer mod.destroyDecl(new_decl_index); | |
| 24526 | const name = name: { | |
| 24527 | const fqn = try union_obj.getFullyQualifiedName(mod); | |
| 24528 | defer sema.gpa.free(fqn); | |
| 24529 | break :name try std.fmt.allocPrintZ(mod.gpa, "@typeInfo({s}).Union.tag_type.?", .{fqn}); | |
| 24530 | }; | |
| 24531 | try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, block.namespace, .{ | |
| 24366 | 24532 | .ty = Type.type, |
| 24367 | 24533 | .val = enum_val, |
| 24368 | }); | |
| 24534 | }, name); | |
| 24535 | sema.mod.declPtr(new_decl_index).name_fully_qualified = true; | |
| 24536 | ||
| 24369 | 24537 | const new_decl = mod.declPtr(new_decl_index); |
| 24370 | 24538 | new_decl.owns_tv = true; |
| 24539 | new_decl.name_fully_qualified = true; | |
| 24371 | 24540 | errdefer mod.abortAnonDecl(new_decl_index); |
| 24372 | 24541 | |
| 24373 | 24542 | enum_obj.* = .{ |
| ... | ... | @@ -24387,7 +24556,7 @@ fn generateUnionTagTypeNumbered( |
| 24387 | 24556 | return enum_ty; |
| 24388 | 24557 | } |
| 24389 | 24558 | |
| 24390 | fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: usize) !Type { | |
| 24559 | fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: usize, maybe_union_obj: ?*Module.Union) !Type { | |
| 24391 | 24560 | const mod = sema.mod; |
| 24392 | 24561 | |
| 24393 | 24562 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| ... | ... | @@ -24402,11 +24571,30 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: usize) !Ty |
| 24402 | 24571 | }; |
| 24403 | 24572 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 24404 | 24573 | const enum_val = try Value.Tag.ty.create(new_decl_arena_allocator, enum_ty); |
| 24405 | // TODO better type name | |
| 24406 | const new_decl_index = try mod.createAnonymousDecl(block, .{ | |
| 24407 | .ty = Type.type, | |
| 24408 | .val = enum_val, | |
| 24409 | }); | |
| 24574 | ||
| 24575 | const new_decl_index = new_decl_index: { | |
| 24576 | const union_obj = maybe_union_obj orelse { | |
| 24577 | break :new_decl_index try mod.createAnonymousDecl(block, .{ | |
| 24578 | .ty = Type.type, | |
| 24579 | .val = enum_val, | |
| 24580 | }); | |
| 24581 | }; | |
| 24582 | const src_decl = mod.declPtr(block.src_decl); | |
| 24583 | const new_decl_index = try mod.allocateNewDecl(block.namespace, src_decl.src_node, block.wip_capture_scope); | |
| 24584 | errdefer mod.destroyDecl(new_decl_index); | |
| 24585 | const name = name: { | |
| 24586 | const fqn = try union_obj.getFullyQualifiedName(mod); | |
| 24587 | defer sema.gpa.free(fqn); | |
| 24588 | break :name try std.fmt.allocPrintZ(mod.gpa, "@typeInfo({s}).Union.tag_type.?", .{fqn}); | |
| 24589 | }; | |
| 24590 | try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, block.namespace, .{ | |
| 24591 | .ty = Type.type, | |
| 24592 | .val = enum_val, | |
| 24593 | }, name); | |
| 24594 | sema.mod.declPtr(new_decl_index).name_fully_qualified = true; | |
| 24595 | break :new_decl_index new_decl_index; | |
| 24596 | }; | |
| 24597 | ||
| 24410 | 24598 | const new_decl = mod.declPtr(new_decl_index); |
| 24411 | 24599 | new_decl.owns_tv = true; |
| 24412 | 24600 | errdefer mod.abortAnonDecl(new_decl_index); |
| ... | ... | @@ -25007,7 +25195,7 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr |
| 25007 | 25195 | // The type is not in-memory coercible or the direct dereference failed, so it must |
| 25008 | 25196 | // be bitcast according to the pointer type we are performing the load through. |
| 25009 | 25197 | if (!load_ty.hasWellDefinedLayout()) |
| 25010 | return sema.fail(block, src, "comptime dereference requires {} to have a well-defined layout, but it does not.", .{load_ty.fmt(sema.mod)}); | |
| 25198 | return sema.fail(block, src, "comptime dereference requires '{}' to have a well-defined layout, but it does not.", .{load_ty.fmt(sema.mod)}); | |
| 25011 | 25199 | |
| 25012 | 25200 | const load_sz = try sema.typeAbiSize(block, src, load_ty); |
| 25013 | 25201 | |
| ... | ... | @@ -25022,11 +25210,11 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr |
| 25022 | 25210 | if (deref.ty_without_well_defined_layout) |bad_ty| { |
| 25023 | 25211 | // We got no parent for bit-casting, or the parent we got was too small. Either way, the problem |
| 25024 | 25212 | // is that some type we encountered when de-referencing does not have a well-defined layout. |
| 25025 | return sema.fail(block, src, "comptime dereference requires {} to have a well-defined layout, but it does not.", .{bad_ty.fmt(sema.mod)}); | |
| 25213 | return sema.fail(block, src, "comptime dereference requires '{}' to have a well-defined layout, but it does not.", .{bad_ty.fmt(sema.mod)}); | |
| 25026 | 25214 | } else { |
| 25027 | 25215 | // If all encountered types had well-defined layouts, the parent is the root decl and it just |
| 25028 | 25216 | // wasn't big enough for the load. |
| 25029 | return sema.fail(block, src, "dereference of {} exceeds bounds of containing decl of type {}", .{ ptr_ty.fmt(sema.mod), deref.parent.?.tv.ty.fmt(sema.mod) }); | |
| 25217 | return sema.fail(block, src, "dereference of '{}' exceeds bounds of containing decl of type '{}'", .{ ptr_ty.fmt(sema.mod), deref.parent.?.tv.ty.fmt(sema.mod) }); | |
| 25030 | 25218 | } |
| 25031 | 25219 | } |
| 25032 | 25220 | |
| ... | ... | @@ -25034,7 +25222,7 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr |
| 25034 | 25222 | /// is too big to fit. |
| 25035 | 25223 | fn usizeCast(sema: *Sema, block: *Block, src: LazySrcLoc, int: u64) CompileError!usize { |
| 25036 | 25224 | if (@bitSizeOf(u64) <= @bitSizeOf(usize)) return int; |
| 25037 | return std.math.cast(usize, int) orelse return sema.fail(block, src, "expression produces integer value {d} which is too big for this compiler implementation to handle", .{int}); | |
| 25225 | return std.math.cast(usize, int) orelse return sema.fail(block, src, "expression produces integer value '{d}' which is too big for this compiler implementation to handle", .{int}); | |
| 25038 | 25226 | } |
| 25039 | 25227 | |
| 25040 | 25228 | /// For pointer-like optionals, it returns the pointer type. For pointers, |
| ... | ... | @@ -25389,7 +25577,7 @@ fn anonStructFieldIndex( |
| 25389 | 25577 | return @intCast(u32, i); |
| 25390 | 25578 | } |
| 25391 | 25579 | } |
| 25392 | return sema.fail(block, field_src, "anonymous struct {} has no such field '{s}'", .{ | |
| 25580 | return sema.fail(block, field_src, "anonymous struct '{}' has no such field '{s}'", .{ | |
| 25393 | 25581 | struct_ty.fmt(sema.mod), field_name, |
| 25394 | 25582 | }); |
| 25395 | 25583 | } |
| ... | ... | @@ -25769,8 +25957,8 @@ fn floatToIntScalar( |
| 25769 | 25957 | else |
| 25770 | 25958 | try Value.Tag.int_big_positive.create(sema.arena, result_limbs); |
| 25771 | 25959 | |
| 25772 | if (!(try sema.intFitsInType(block, src, result, int_ty))) { | |
| 25773 | return sema.fail(block, src, "float value {} cannot be stored in integer type '{}'", .{ | |
| 25960 | if (!(try sema.intFitsInType(block, src, result, int_ty, null))) { | |
| 25961 | return sema.fail(block, src, "float value '{}' cannot be stored in integer type '{}'", .{ | |
| 25774 | 25962 | val.fmtValue(float_ty, sema.mod), int_ty.fmt(sema.mod), |
| 25775 | 25963 | }); |
| 25776 | 25964 | } |
| ... | ... | @@ -25785,6 +25973,7 @@ fn intFitsInType( |
| 25785 | 25973 | src: LazySrcLoc, |
| 25786 | 25974 | self: Value, |
| 25787 | 25975 | ty: Type, |
| 25976 | vector_index: ?*usize, | |
| 25788 | 25977 | ) CompileError!bool { |
| 25789 | 25978 | const target = sema.mod.getTarget(); |
| 25790 | 25979 | switch (self.tag()) { |
| ... | ... | @@ -25894,8 +26083,9 @@ fn intFitsInType( |
| 25894 | 26083 | |
| 25895 | 26084 | .aggregate => { |
| 25896 | 26085 | assert(ty.zigTypeTag() == .Vector); |
| 25897 | for (self.castTag(.aggregate).?.data) |elem| { | |
| 25898 | if (!(try sema.intFitsInType(block, src, elem, ty.scalarType()))) { | |
| 26086 | for (self.castTag(.aggregate).?.data) |elem, i| { | |
| 26087 | if (!(try sema.intFitsInType(block, src, elem, ty.scalarType(), null))) { | |
| 26088 | if (vector_index) |some| some.* = i; | |
| 25899 | 26089 | return false; |
| 25900 | 26090 | } |
| 25901 | 26091 | } |
| ... | ... | @@ -25933,7 +26123,7 @@ fn enumHasInt( |
| 25933 | 26123 | int: Value, |
| 25934 | 26124 | ) CompileError!bool { |
| 25935 | 26125 | switch (ty.tag()) { |
| 25936 | .enum_nonexhaustive => return sema.intFitsInType(block, src, int, ty), | |
| 26126 | .enum_nonexhaustive => return sema.intFitsInType(block, src, int, ty, null), | |
| 25937 | 26127 | .enum_full => { |
| 25938 | 26128 | const enum_full = ty.castTag(.enum_full).?.data; |
| 25939 | 26129 | const tag_ty = enum_full.tag_ty; |
src/TypedValue.zig+5-5| ... | ... | @@ -409,11 +409,11 @@ pub fn print( |
| 409 | 409 | } |
| 410 | 410 | return writer.writeAll(" }"); |
| 411 | 411 | }, |
| 412 | .float_16 => return writer.print("{}", .{val.castTag(.float_16).?.data}), | |
| 413 | .float_32 => return writer.print("{}", .{val.castTag(.float_32).?.data}), | |
| 414 | .float_64 => return writer.print("{}", .{val.castTag(.float_64).?.data}), | |
| 415 | .float_80 => return writer.print("{}", .{val.castTag(.float_80).?.data}), | |
| 416 | .float_128 => return writer.print("{}", .{val.castTag(.float_128).?.data}), | |
| 412 | .float_16 => return writer.print("{d}", .{val.castTag(.float_16).?.data}), | |
| 413 | .float_32 => return writer.print("{d}", .{val.castTag(.float_32).?.data}), | |
| 414 | .float_64 => return writer.print("{d}", .{val.castTag(.float_64).?.data}), | |
| 415 | .float_80 => return writer.print("{d}", .{@floatCast(f64, val.castTag(.float_80).?.data)}), | |
| 416 | .float_128 => return writer.print("{d}", .{@floatCast(f64, val.castTag(.float_128).?.data)}), | |
| 417 | 417 | .@"error" => return writer.print("error.{s}", .{val.castTag(.@"error").?.data.name}), |
| 418 | 418 | .eu_payload => { |
| 419 | 419 | val = val.castTag(.eu_payload).?.data; |
src/Zir.zig+2-2| ... | ... | @@ -308,7 +308,7 @@ pub const Inst = struct { |
| 308 | 308 | cmp_neq, |
| 309 | 309 | /// Coerces a result location pointer to a new element type. It is evaluated "backwards"- |
| 310 | 310 | /// as type coercion from the new element type to the old element type. |
| 311 | /// Uses the `bin` union field. | |
| 311 | /// Uses the `pl_node` union field. Payload is `Bin`. | |
| 312 | 312 | /// LHS is destination element type, RHS is result pointer. |
| 313 | 313 | coerce_result_ptr, |
| 314 | 314 | /// Conditional branch. Splits control flow based on a boolean condition value. |
| ... | ... | @@ -1603,7 +1603,7 @@ pub const Inst = struct { |
| 1603 | 1603 | .cmp_gte = .pl_node, |
| 1604 | 1604 | .cmp_gt = .pl_node, |
| 1605 | 1605 | .cmp_neq = .pl_node, |
| 1606 | .coerce_result_ptr = .bin, | |
| 1606 | .coerce_result_ptr = .pl_node, | |
| 1607 | 1607 | .condbr = .pl_node, |
| 1608 | 1608 | .condbr_inline = .pl_node, |
| 1609 | 1609 | .@"try" = .pl_node, |
src/codegen/llvm.zig+17-18| ... | ... | @@ -7634,33 +7634,31 @@ pub const FuncGen = struct { |
| 7634 | 7634 | fn airTagName(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { |
| 7635 | 7635 | if (self.liveness.isUnused(inst)) return null; |
| 7636 | 7636 | |
| 7637 | var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); | |
| 7638 | defer arena_allocator.deinit(); | |
| 7639 | const arena = arena_allocator.allocator(); | |
| 7640 | ||
| 7641 | 7637 | const un_op = self.air.instructions.items(.data)[inst].un_op; |
| 7642 | 7638 | const operand = try self.resolveInst(un_op); |
| 7643 | 7639 | const enum_ty = self.air.typeOf(un_op); |
| 7644 | 7640 | |
| 7645 | const mod = self.dg.module; | |
| 7646 | const llvm_fn_name = try std.fmt.allocPrintZ(arena, "__zig_tag_name_{s}", .{ | |
| 7647 | try mod.declPtr(enum_ty.getOwnerDecl()).getFullyQualifiedName(mod), | |
| 7648 | }); | |
| 7649 | ||
| 7650 | const llvm_fn = try self.getEnumTagNameFunction(enum_ty, llvm_fn_name); | |
| 7641 | const llvm_fn = try self.getEnumTagNameFunction(enum_ty); | |
| 7651 | 7642 | const params = [_]*const llvm.Value{operand}; |
| 7652 | 7643 | return self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, ""); |
| 7653 | 7644 | } |
| 7654 | 7645 | |
| 7655 | fn getEnumTagNameFunction( | |
| 7656 | self: *FuncGen, | |
| 7657 | enum_ty: Type, | |
| 7658 | llvm_fn_name: [:0]const u8, | |
| 7659 | ) !*const llvm.Value { | |
| 7646 | fn getEnumTagNameFunction(self: *FuncGen, enum_ty: Type) !*const llvm.Value { | |
| 7647 | const enum_decl = enum_ty.getOwnerDecl(); | |
| 7648 | ||
| 7660 | 7649 | // TODO: detect when the type changes and re-emit this function. |
| 7661 | if (self.dg.object.llvm_module.getNamedFunction(llvm_fn_name)) |llvm_fn| { | |
| 7662 | return llvm_fn; | |
| 7663 | } | |
| 7650 | const gop = try self.dg.object.decl_map.getOrPut(self.dg.gpa, enum_decl); | |
| 7651 | if (gop.found_existing) return gop.value_ptr.*; | |
| 7652 | errdefer assert(self.dg.object.decl_map.remove(enum_decl)); | |
| 7653 | ||
| 7654 | var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); | |
| 7655 | defer arena_allocator.deinit(); | |
| 7656 | const arena = arena_allocator.allocator(); | |
| 7657 | ||
| 7658 | const mod = self.dg.module; | |
| 7659 | const llvm_fn_name = try std.fmt.allocPrintZ(arena, "__zig_tag_name_{s}", .{ | |
| 7660 | try mod.declPtr(enum_decl).getFullyQualifiedName(mod), | |
| 7661 | }); | |
| 7664 | 7662 | |
| 7665 | 7663 | const slice_ty = Type.initTag(.const_slice_u8_sentinel_0); |
| 7666 | 7664 | const llvm_ret_ty = try self.dg.lowerType(slice_ty); |
| ... | ... | @@ -7677,6 +7675,7 @@ pub const FuncGen = struct { |
| 7677 | 7675 | fn_val.setLinkage(.Internal); |
| 7678 | 7676 | fn_val.setFunctionCallConv(.Fast); |
| 7679 | 7677 | self.dg.addCommonFnAttributes(fn_val); |
| 7678 | gop.value_ptr.* = fn_val; | |
| 7680 | 7679 | |
| 7681 | 7680 | const prev_block = self.builder.getInsertBlock(); |
| 7682 | 7681 | const prev_debug_location = self.builder.getCurrentDebugLocation2(); |
src/print_zir.zig+1-1| ... | ... | @@ -144,7 +144,6 @@ const Writer = struct { |
| 144 | 144 | switch (tag) { |
| 145 | 145 | .array_type, |
| 146 | 146 | .as, |
| 147 | .coerce_result_ptr, | |
| 148 | 147 | .elem_ptr, |
| 149 | 148 | .elem_val, |
| 150 | 149 | .store, |
| ... | ... | @@ -355,6 +354,7 @@ const Writer = struct { |
| 355 | 354 | .minimum, |
| 356 | 355 | .elem_ptr_node, |
| 357 | 356 | .elem_val_node, |
| 357 | .coerce_result_ptr, | |
| 358 | 358 | => try self.writePlNodeBin(stream, inst), |
| 359 | 359 | |
| 360 | 360 | .elem_ptr_imm => try self.writeElemPtrImm(stream, inst), |
test/behavior/enum.zig+21| ... | ... | @@ -1107,3 +1107,24 @@ test "enum literal in array literal" { |
| 1107 | 1107 | try expect(array[0] == .one); |
| 1108 | 1108 | try expect(array[1] == .two); |
| 1109 | 1109 | } |
| 1110 | ||
| 1111 | test "tag name functions are unique" { | |
| 1112 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 1113 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 1114 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 1115 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 1116 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 1117 | ||
| 1118 | { | |
| 1119 | const E = enum { a, b }; | |
| 1120 | var b = E.a; | |
| 1121 | var a = @tagName(b); | |
| 1122 | _ = a; | |
| 1123 | } | |
| 1124 | { | |
| 1125 | const E = enum { a, b, c, d, e, f }; | |
| 1126 | var b = E.a; | |
| 1127 | var a = @tagName(b); | |
| 1128 | _ = a; | |
| 1129 | } | |
| 1130 | } |
test/cases/aarch64-macos/hello_world_with_updates.1.zig+1-1| ... | ... | @@ -2,4 +2,4 @@ pub export fn main() noreturn {} |
| 2 | 2 | |
| 3 | 3 | // error |
| 4 | 4 | // |
| 5 | // :1:32: error: expected noreturn, found void | |
| 5 | // :1:32: error: expected type 'noreturn', found 'void' |
test/cases/bad_inferred_variable_type.zig+1| ... | ... | @@ -5,5 +5,6 @@ pub fn main() void { |
| 5 | 5 | |
| 6 | 6 | // error |
| 7 | 7 | // output_mode=Exe |
| 8 | // backend=stage2 | |
| 8 | 9 | // |
| 9 | 10 | // :2:9: error: variable of type '@TypeOf(null)' must be const or comptime |
test/cases/comparison_of_non-tagged_union_and_enum_literal.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry() void { | |
| 2 | const U = union { A: u32, B: u64 }; | |
| 3 | var u = U{ .A = 42 }; | |
| 4 | var ok = u == .A; | |
| 5 | _ = ok; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:14: error: comparison of union and enum literal is only valid for tagged union types | |
| 13 | // :2:15: note: union 'tmp.entry.U' is not a tagged union |
test/cases/compile_errors/Issue_5586_Make_unary_minus_for_unsigned_types_a_compile_error.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | export fn f1(x: u32) u32 { | |
| 2 | const y = -%x; | |
| 3 | return -y; | |
| 4 | } | |
| 5 | const V = @import("std").meta.Vector; | |
| 6 | export fn f2(x: V(4, u32)) V(4, u32) { | |
| 7 | const y = -%x; | |
| 8 | return -y; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage2 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // :3:12: error: negation of type 'u32' | |
| 16 | // :8:12: error: negation of type '@Vector(4, u32)' |
test/cases/compile_errors/Issue_6823_dont_allow_._to_be_followed_by_.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn foo() void { | |
| 2 | var sequence = "repeat".*** 10; | |
| 3 | _ = sequence; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:28: error: '.*' cannot be followed by '*'. Are you missing a space? |
test/cases/compile_errors/access_invalid_typeInfo_decl.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const A = B; | |
| 2 | test "Crash" { | |
| 3 | _ = @typeInfo(@This()).Struct.decls[0]; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // :1:11: error: use of undeclared identifier 'B' |
test/cases/compile_errors/access_non-existent_member_of_error_set.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const Foo = error{A}; | |
| 2 | comptime { | |
| 3 | const z = Foo.Bar; | |
| 4 | _ = z; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:18: error: no error named 'Bar' in 'error{A}' | |
| 12 | // :1:13: note: error set declared here |
test/cases/compile_errors/add_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a += a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/add_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a + a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:13: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/add_overflow_in_function_evaluation.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const y = add(65530, 10); | |
| 2 | fn add(a: u16, b: u16) u16 { | |
| 3 | return a + b; | |
| 4 | } | |
| 5 | ||
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(y)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :3:14: error: overflow of integer type 'u16' with value '65540' | |
| 13 | // :1:14: note: called from here |
test/cases/compile_errors/addition_with_non_numbers.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const Foo = struct { | |
| 2 | field: i32, | |
| 3 | }; | |
| 4 | const x = Foo {.field = 1} + Foo {.field = 2}; | |
| 5 | ||
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(x)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=llvm | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:28: error: invalid operands to binary expression: 'Struct' and 'Struct' |
test/cases/compile_errors/address_of_number_literal.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const x = 3; | |
| 2 | const y = &x; | |
| 3 | fn foo() *const i32 { return y; } | |
| 4 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:30: error: expected type '*const i32', found '*const comptime_int' |
test/cases/compile_errors/alignCast_expects_pointer_or_slice.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | @alignCast(4, @as(u32, 3)); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:19: error: expected pointer type, found 'u32' |
test/cases/compile_errors/alignment_of_enum_field_specified.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const Number = enum { | |
| 2 | a, | |
| 3 | b align(i32), | |
| 4 | }; | |
| 5 | export fn entry1() void { | |
| 6 | var x: Number = undefined; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :3:7: error: expected ',' after field |
test/cases/compile_errors/ambiguous_decl_reference.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | fn foo() void {} | |
| 2 | fn bar() void { | |
| 3 | const S = struct { | |
| 4 | fn baz() void { | |
| 5 | foo(); | |
| 6 | } | |
| 7 | fn foo() void {} | |
| 8 | }; | |
| 9 | S.baz(); | |
| 10 | } | |
| 11 | export fn entry() void { | |
| 12 | bar(); | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage2 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // :5:13: error: ambiguous reference | |
| 20 | // :7:9: note: declared here | |
| 21 | // :1:1: note: also declared here |
test/cases/compile_errors/any_typed_null_to_any_typed_optional.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: ?*anyopaque = undefined; | |
| 3 | a = @as(?usize, null); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // output_mode=Exe | |
| 8 | // backend=stage2,llvm | |
| 9 | // target=x86_64-linux,x86_64-macos | |
| 10 | // | |
| 11 | // :3:21: error: expected type '*anyopaque', found '?usize' |
test/cases/compile_errors/array_access_of_undeclared_identifier.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn f() void { | |
| 2 | i[i] = i[i]; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: use of undeclared identifier 'i' |
test/cases/compile_errors/array_concatenation_with_wrong_type.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const src = "aoeu"; | |
| 2 | const derp: usize = 1234; | |
| 3 | const a = derp ++ "foo"; | |
| 4 | ||
| 5 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:11: error: expected indexable; found 'usize' |
test/cases/compile_errors/asm_at_compile_time.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | comptime { | |
| 2 | doSomeAsm(); | |
| 3 | } | |
| 4 | ||
| 5 | fn doSomeAsm() void { | |
| 6 | asm volatile ( | |
| 7 | \\.globl aoeu; | |
| 8 | \\.type aoeu, @function; | |
| 9 | \\.set aoeu, derp; | |
| 10 | ); | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=llvm | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :6:5: error: unable to evaluate constant expression |
test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | var a = &b; | |
| 3 | _ = a; | |
| 4 | } | |
| 5 | fn b() callconv(.Inline) void { } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:9: error: variable of type '*const fn() callconv(.Inline) void' must be const or comptime | |
| 12 | // :2:9: note: function has inline calling convention |
test/cases/compile_errors/assign_null_to_non-optional_pointer.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const a: *u8 = null; | |
| 2 | ||
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :1:16: error: expected type '*u8', found '@TypeOf(null)' |
test/cases/compile_errors/assign_through_constant_pointer.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f() void { | |
| 2 | var cstr = "Hat"; | |
| 3 | cstr[0] = 'W'; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:13: error: cannot assign to constant |
test/cases/compile_errors/assign_through_constant_slice.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f() void { | |
| 2 | var cstr: []const u8 = "Hat"; | |
| 3 | cstr[0] = 'W'; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:13: error: cannot assign to constant |
test/cases/compile_errors/assign_to_constant_field.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Foo = struct { | |
| 2 | field: i32, | |
| 3 | }; | |
| 4 | export fn derp() void { | |
| 5 | const f = Foo {.field = 1234,}; | |
| 6 | f.field = 0; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :6:15: error: cannot assign to constant |
test/cases/compile_errors/assign_to_constant_variable.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f() void { | |
| 2 | const a = 3; | |
| 3 | a = 4; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:9: error: cannot assign to constant |
test/cases/compile_errors/assign_too_big_number_to_u16.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn foo() void { | |
| 2 | var vga_mem: u16 = 0xB8000; | |
| 3 | _ = vga_mem; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:24: error: type 'u16' cannot represent integer value '753664' |
test/cases/compile_errors/assign_unreachable.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn f() void { | |
| 2 | const a = return; | |
| 3 | _ = a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:5: error: unreachable code | |
| 11 | // :2:15: note: control flow is diverted here |
test/cases/compile_errors/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: u32 = 0; | |
| 3 | @atomicStore(u32, &x, 1, .Acquire); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:31: error: @atomicStore atomic ordering must not be Acquire or AcqRel |
test/cases/compile_errors/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; | |
| 2 | export fn f() void { | |
| 3 | var x: i32 = 1234; | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Monotonic, AtomicOrder.SeqCst)) {} | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :4:81: error: failure atomic ordering must be no stricter than success |
test/cases/compile_errors/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; | |
| 2 | export fn f() void { | |
| 3 | var x: i32 = 1234; | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Unordered, AtomicOrder.Unordered)) {} | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :4:58: error: success atomic ordering must be Monotonic or stricter |
test/cases/compile_errors/atomic_orderings_of_fence_Acquire_or_stricter.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | @fence(.Monotonic); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:13: error: atomic ordering must be Acquire or stricter |
test/cases/compile_errors/atomicrmw_with_bool_op_not_.Xchg.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var x = false; | |
| 3 | _ = @atomicRmw(bool, &x, .Add, true, .SeqCst); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:31: error: @atomicRmw with bool only allowed with .Xchg |
test/cases/compile_errors/atomicrmw_with_enum_op_not_.Xchg.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | export fn entry() void { | |
| 2 | const E = enum(u8) { | |
| 3 | a, | |
| 4 | b, | |
| 5 | c, | |
| 6 | d, | |
| 7 | }; | |
| 8 | var x: E = .a; | |
| 9 | _ = @atomicRmw(E, &x, .Add, .b, .SeqCst); | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :9:28: error: @atomicRmw with enum only allowed with .Xchg |
test/cases/compile_errors/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: f32 = 0; | |
| 3 | _ = @atomicRmw(f32, &x, .And, 2, .SeqCst); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, and .Sub |
test/cases/compile_errors/attempt_to_cast_enum_literal_to_error.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | switch (error.Hi) { | |
| 3 | .Hi => {}, | |
| 4 | } | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:10: error: expected type 'error{Hi}', found '@TypeOf(.enum_literal)' |
test/cases/compile_errors/attempt_to_close_over_comptime_variable_from_outer_scope.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | fn SimpleList(comptime L: usize) type { | |
| 2 | var T = u8; | |
| 3 | return struct { | |
| 4 | array: [L]T, | |
| 5 | }; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:19: error: mutable 'T' not accessible from here | |
| 13 | // :2:9: note: declared mutable here | |
| 14 | // :3:12: note: crosses namespace boundary here |
test/cases/compile_errors/attempt_to_create_17_bit_float_type.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const builtin = @import("std").builtin; | |
| 2 | comptime { | |
| 3 | _ = @Type(.{ .Float = .{ .bits = 17 } }); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:9: error: 17-bit float unsupported |
test/cases/compile_errors/attempt_to_negate_a_non-integer_non-float_or_non-vector_type.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | fn foo() anyerror!u32 { | |
| 2 | return 1; | |
| 3 | } | |
| 4 | ||
| 5 | export fn entry() void { | |
| 6 | const x = -foo(); | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :6:15: error: negation of type 'anyerror!u32' |
test/cases/compile_errors/attempted_double_ampersand.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry(a: bool, b: bool) i32 { | |
| 2 | if (a && b) { | |
| 3 | return 1234; | |
| 4 | } | |
| 5 | return 5678; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:11: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND |
test/cases/compile_errors/attempted_double_pipe_on_boolean_values.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry(a: bool, b: bool) i32 { | |
| 2 | if (a || b) { | |
| 3 | return 1234; | |
| 4 | } | |
| 5 | return 5678; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:9: error: expected error set type, found 'bool' | |
| 13 | // :2:11: note: '||' merges error sets; 'or' performs boolean OR |
test/cases/compile_errors/attempted_implicit_cast_from_T_to_slice_const_T.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x: [*]const bool = true; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:30: error: expected type '[*]const bool', found 'bool' |
test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_sliceT.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | const u: u32 = 42; | |
| 3 | const x: []u32 = &u; | |
| 4 | _ = x; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:22: error: expected type '[]u32', found '*const u32' |
test/cases/compile_errors/bad_identifier_in_function_with_struct_defined_inside_function_which_references_local_const.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | export fn entry() void { | |
| 2 | const BlockKind = u32; | |
| 3 | ||
| 4 | const Block = struct { | |
| 5 | kind: BlockKind, | |
| 6 | }; | |
| 7 | ||
| 8 | bogus; | |
| 9 | ||
| 10 | _ = Block; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :8:5: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/bad_import.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | const bogus = @import("bogus-does-not-exist.zig",); | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:23: error: unable to load '${DIR}bogus-does-not-exist.zig': FileNotFound |
test/cases/compile_errors/bad_splat_type.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | const c = 4; | |
| 3 | var v = @splat(4, c); | |
| 4 | _ = v; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:23: error: expected integer, float, bool, or pointer for the vector element type; found 'comptime_int' |
test/cases/compile_errors/bad_usage_of_call.zig created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | export fn entry1() void { | |
| 2 | @call(.{}, foo, {}); | |
| 3 | } | |
| 4 | export fn entry2() void { | |
| 5 | comptime @call(.{ .modifier = .never_inline }, foo, .{}); | |
| 6 | } | |
| 7 | export fn entry3() void { | |
| 8 | comptime @call(.{ .modifier = .never_tail }, foo, .{}); | |
| 9 | } | |
| 10 | export fn entry4() void { | |
| 11 | @call(.{ .modifier = .never_inline }, bar, .{}); | |
| 12 | } | |
| 13 | export fn entry5(c: bool) void { | |
| 14 | var baz = if (c) &baz1 else &baz2; | |
| 15 | @call(.{ .modifier = .compile_time }, baz, .{}); | |
| 16 | } | |
| 17 | pub export fn entry() void { | |
| 18 | var call_me: *const fn () void = undefined; | |
| 19 | @call(.{ .modifier = .always_inline }, call_me, .{}); | |
| 20 | } | |
| 21 | fn foo() void {} | |
| 22 | fn bar() callconv(.Inline) void {} | |
| 23 | fn baz1() void {} | |
| 24 | fn baz2() void {} | |
| 25 | ||
| 26 | // error | |
| 27 | // backend=stage2 | |
| 28 | // target=native | |
| 29 | // | |
| 30 | // :2:21: error: expected a tuple, found 'void' | |
| 31 | // :5:21: error: unable to perform 'never_inline' call at compile-time | |
| 32 | // :8:21: error: unable to perform 'never_tail' call at compile-time | |
| 33 | // :11:5: error: no-inline call of inline function | |
| 34 | // :15:43: error: modifier 'compile_time' requires a comptime-known function | |
| 35 | // :19:44: error: modifier 'always_inline' requires a comptime-known function |
test/cases/compile_errors/binary_OR_operator_on_error_sets.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub const A = error.A; | |
| 2 | pub const AB = A | error.B; | |
| 3 | export fn entry() void { | |
| 4 | var x: AB = undefined; | |
| 5 | _ = x; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:18: error: invalid operands to binary bitwise expression: 'ErrorSet' and 'ErrorSet' |
test/cases/compile_errors/binary_not_on_number_literal.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const TINY_QUANTUM_SHIFT = 4; | |
| 2 | const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT; | |
| 3 | var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1); | |
| 4 | ||
| 5 | export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:60: error: unable to perform binary not operation on type 'comptime_int' |
test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry(byte: u8) void { | |
| 2 | var oops = @bitCast(u7, byte); | |
| 3 | _ = oops; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:29: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits |
test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var foo = (@bitCast(u8, @as(f32, 1.0)) == 0xf); | |
| 3 | _ = foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:29: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits |
test/cases/compile_errors/bit_shifting_only_works_on_integer_types.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = &@as(u8, 1) << 10; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:15: error: bit shifting operation expected integer type, found '*const u8' |
test/cases/compile_errors/bogus_method_call_on_slice.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | var self = "aoeu"; | |
| 2 | fn f(m: []const u8) void { | |
| 3 | m.copy(u8, self[0..], m); | |
| 4 | } | |
| 5 | export fn entry() usize { return @sizeOf(@TypeOf(&f)); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:6: error: type '[]const u8' has no field or member function named 'copy' |
test/cases/compile_errors/branch_on_undefined_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const x = if (undefined) true else false; | |
| 2 | ||
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(x)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :1:15: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/call_assigned_to_constant.zig created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | const Foo = struct { | |
| 2 | x: i32, | |
| 3 | }; | |
| 4 | fn foo() Foo { | |
| 5 | return .{ .x = 42 }; | |
| 6 | } | |
| 7 | fn bar(val: anytype) Foo { | |
| 8 | return .{ .x = val }; | |
| 9 | } | |
| 10 | export fn entry() void { | |
| 11 | const baz: Foo = undefined; | |
| 12 | baz = foo(); | |
| 13 | } | |
| 14 | export fn entry1() void { | |
| 15 | const baz: Foo = undefined; | |
| 16 | baz = bar(42); | |
| 17 | } | |
| 18 | ||
| 19 | // error | |
| 20 | // backend=stage2 | |
| 21 | // target=native | |
| 22 | // | |
| 23 | // :12:14: error: cannot assign to constant | |
| 24 | // :16:14: error: cannot assign to constant |
test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | foo("hello".*,); | |
| 3 | } | |
| 4 | pub extern fn foo(format: *const u8, ...) void; | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:8: error: expected type '*const u8', found '[5:0]u8' |
test/cases/compile_errors/cast_enum_literal_to_enum_but_it_doesnt_match.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const Foo = enum { | |
| 2 | a, | |
| 3 | b, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const x: Foo = .c; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :6:21: error: enum 'tmp.Foo' has no field named 'c' | |
| 15 | // :1:13: note: enum declared here |
test/cases/compile_errors/cast_negative_integer_literal_to_usize.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @as(usize, -10); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:26: error: type 'usize' cannot represent integer value '-10' |
test/cases/compile_errors/cast_negative_value_to_unsigned_integer.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | comptime { | |
| 2 | const value: i32 = -1; | |
| 3 | const unsigned = @intCast(u32, value); | |
| 4 | _ = unsigned; | |
| 5 | } | |
| 6 | export fn entry1() void { | |
| 7 | const value: i32 = -1; | |
| 8 | const unsigned: u32 = value; | |
| 9 | _ = unsigned; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=llvm | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :3:36: error: type 'u32' cannot represent integer value '-1' | |
| 17 | // :8:27: error: type 'u32' cannot represent integer value '-1' |
test/cases/compile_errors/cast_unreachable.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | fn f() i32 { | |
| 2 | return @as(i32, return 1); | |
| 3 | } | |
| 4 | export fn entry() void { _ = f(); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:12: error: unreachable code | |
| 11 | // :2:21: note: control flow is diverted here | |
| 12 | // :2:5: error: unreachable code | |
| 13 | // :2:12: note: control flow is diverted here |
test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | const BitField = packed struct { | |
| 2 | a: u3, | |
| 3 | b: u3, | |
| 4 | c: u2, | |
| 5 | }; | |
| 6 | ||
| 7 | fn foo(bit_field: *const BitField) u3 { | |
| 8 | return bar(&bit_field.b); | |
| 9 | } | |
| 10 | ||
| 11 | fn bar(x: *const u3) u3 { | |
| 12 | return x.*; | |
| 13 | } | |
| 14 | ||
| 15 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 16 | ||
| 17 | // error | |
| 18 | // backend=stage2 | |
| 19 | // target=native | |
| 20 | // | |
| 21 | // :8:15: error: expected type '*const u3', found '*align(0:3:1) const u3' |
test/cases/compile_errors/chained_comparison_operators.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a(value: u32) bool { | |
| 2 | return 1 < value < 1000; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:22: error: comparison operators cannot be chained |
test/cases/compile_errors/cmpxchg_with_float.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: f32 = 0; | |
| 3 | _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:22: error: expected bool, integer, enum, or pointer type; found 'f32' |
test/cases/compile_errors/colliding_invalid_top_level_functions.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | fn func() bogus {} | |
| 2 | fn func() bogus {} | |
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(func)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:1: error: redeclaration of 'func' | |
| 10 | // :1:1: note: other declaration here | |
| 11 | // :1:11: error: use of undeclared identifier 'bogus' | |
| 12 | // :2:11: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/combination_of_nosuspend_and_async.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | export fn entry() void { | |
| 2 | nosuspend { | |
| 3 | const bar = async foo(); | |
| 4 | suspend {} | |
| 5 | resume bar; | |
| 6 | } | |
| 7 | } | |
| 8 | fn foo() void {} | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :4:9: error: suspend inside nosuspend block | |
| 15 | // :2:5: note: nosuspend block here |
test/cases/compile_errors/comparing_a_non-optional_pointer_against_null.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: i32 = 1; | |
| 3 | _ = &x == null; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:12: error: comparison of '*i32' with null |
test/cases/compile_errors/comparing_against_undefined_produces_undefined_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | if (2 == undefined) {} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/comparison_operators_with_undefined_value.zig created+47| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | // operator == | |
| 2 | comptime { | |
| 3 | var a: i64 = undefined; | |
| 4 | var x: i32 = 0; | |
| 5 | if (a == a) x += 1; | |
| 6 | } | |
| 7 | // operator != | |
| 8 | comptime { | |
| 9 | var a: i64 = undefined; | |
| 10 | var x: i32 = 0; | |
| 11 | if (a != a) x += 1; | |
| 12 | } | |
| 13 | // operator > | |
| 14 | comptime { | |
| 15 | var a: i64 = undefined; | |
| 16 | var x: i32 = 0; | |
| 17 | if (a > a) x += 1; | |
| 18 | } | |
| 19 | // operator < | |
| 20 | comptime { | |
| 21 | var a: i64 = undefined; | |
| 22 | var x: i32 = 0; | |
| 23 | if (a < a) x += 1; | |
| 24 | } | |
| 25 | // operator >= | |
| 26 | comptime { | |
| 27 | var a: i64 = undefined; | |
| 28 | var x: i32 = 0; | |
| 29 | if (a >= a) x += 1; | |
| 30 | } | |
| 31 | // operator <= | |
| 32 | comptime { | |
| 33 | var a: i64 = undefined; | |
| 34 | var x: i32 = 0; | |
| 35 | if (a <= a) x += 1; | |
| 36 | } | |
| 37 | ||
| 38 | // error | |
| 39 | // backend=stage2 | |
| 40 | // target=native | |
| 41 | // | |
| 42 | // :5:11: error: use of undefined value here causes undefined behavior | |
| 43 | // :11:11: error: use of undefined value here causes undefined behavior | |
| 44 | // :17:11: error: use of undefined value here causes undefined behavior | |
| 45 | // :23:11: error: use of undefined value here causes undefined behavior | |
| 46 | // :29:11: error: use of undefined value here causes undefined behavior | |
| 47 | // :35:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/comparison_with_error_union_and_error_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var number_or_error: anyerror!i32 = error.SomethingAwful; | |
| 3 | _ = number_or_error == error.SomethingAwful; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:25: error: operator == not allowed for type 'anyerror!i32' |
test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const foo = @compileError("aoeu",); | |
| 2 | ||
| 3 | const bar = baz + foo; | |
| 4 | const baz = 1; | |
| 5 | ||
| 6 | export fn entry() i32 { | |
| 7 | return bar; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :1:13: error: aoeu |
test/cases/compile_errors/compile_error_in_struct_init_expression.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const Foo = struct { | |
| 2 | a: i32 = crap, | |
| 3 | b: i32, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | var x = Foo{ | |
| 7 | .b = 5, | |
| 8 | }; | |
| 9 | _ = x; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :2:14: error: use of undeclared identifier 'crap' |
test/cases/compile_errors/compile_error_when_evaluating_return_type_of_inferred_error_set.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const Car = struct { | |
| 2 | foo: *SymbolThatDoesNotExist, | |
| 3 | pub fn init() !Car {} | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const car = Car.init(); | |
| 7 | _ = car; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist' |
test/cases/compile_errors/compile_log_a_pointer_to_an_opaque_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | @compileLog(@ptrCast(*const anyopaque, &entry)); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: found compile log statement |
test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | export fn entry() void { | |
| 2 | inner(1); | |
| 3 | inner(2); | |
| 4 | } | |
| 5 | fn inner(comptime n: usize) void { | |
| 6 | comptime var i = 0; | |
| 7 | inline while (i < n) : (i += 1) { @compileLog("!@#$"); } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=llvm | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :7:39: error: found compile log statement | |
| 15 | // :7:39: note: also here |
test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | const Letter = enum { A, B, C }; | |
| 2 | const Value = union(Letter) { | |
| 3 | A: i32, | |
| 4 | B, | |
| 5 | C, | |
| 6 | }; | |
| 7 | export fn entry() void { | |
| 8 | var x: Value = Letter.A; | |
| 9 | _ = x; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :8:26: error: coercion from enum 'tmp.Letter' to union 'tmp.Value' must initialize 'i32' field 'A' | |
| 17 | // :3:5: note: field 'A' declared here | |
| 18 | // :2:15: note: union declared here |
test/cases/compile_errors/comptime_slice_of_undefined_pointer_non-zero_len.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const slice = @as([*]i32, undefined)[0..1]; | |
| 3 | _ = slice; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:41: error: non-zero length slice of undefined pointer |
test/cases/compile_errors/comptime_struct_field_no_init_value.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Foo = struct { | |
| 2 | comptime b: i32, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var f: Foo = undefined; | |
| 6 | _ = f; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :2:5: error: comptime field without default initialization value |
test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | comptime { | |
| 2 | var a: @import("std").meta.Vector(4, u8) = [_]u8{ 1, 2, 255, 4 }; | |
| 3 | var b: @import("std").meta.Vector(4, u8) = [_]u8{ 5, 6, 1, 8 }; | |
| 4 | var x = a + b; | |
| 5 | _ = x; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:15: error: overflow of vector type '@Vector(4, u8)' with value '.{ 6, 8, 256, 12 }' | |
| 13 | // :4:15: note: when computing vector element at index '2' |
test/cases/compile_errors/const_is_a_statement_not_an_expression.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn f() void { | |
| 2 | (const a = 0); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:6: error: expected expression, found 'const' |
test/cases/compile_errors/container_init_with_non-type.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const zero: i32 = 0; | |
| 2 | const a = zero{1}; | |
| 3 | ||
| 4 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:15: error: expected type 'type', found 'i32' |
test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | export fn foo() void { | |
| 2 | comptime var i = 0; | |
| 3 | while (i < 5) : (i += 1) { | |
| 4 | bar(); | |
| 5 | } | |
| 6 | } | |
| 7 | ||
| 8 | fn bar() void { } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :3:24: error: cannot store to comptime variable in non-inline loop | |
| 15 | // :3:5: note: non-inline loop here |
test/cases/compile_errors/declaration_between_fields.zig created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | const S = struct { | |
| 2 | const foo = 2; | |
| 3 | const bar = 2; | |
| 4 | const baz = 2; | |
| 5 | a: struct { | |
| 6 | a: u32, | |
| 7 | b: u32, | |
| 8 | }, | |
| 9 | const foo1 = 2; | |
| 10 | const bar1 = 2; | |
| 11 | const baz1 = 2; | |
| 12 | b: usize, | |
| 13 | }; | |
| 14 | comptime { | |
| 15 | _ = S; | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage2 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // :9:5: error: declarations are not allowed between container fields | |
| 23 | // :5:5: note: field before declarations here | |
| 24 | // :12:5: note: field after declarations here |
test/cases/compile_errors/declaration_with_same_name_as_primitive_must_use_special_syntax.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const u8 = u16; | |
| 2 | export fn entry() void { | |
| 3 | const a: u8 = 300; | |
| 4 | _ = a; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :1:7: error: name shadows primitive 'u8' | |
| 12 | // :1:7: note: consider using @"u8" to disambiguate |
test/cases/compile_errors/deduplicate_undeclared_identifier.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn a() void { | |
| 2 | x += 1; | |
| 3 | } | |
| 4 | export fn b() void { | |
| 5 | x += 1; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:5: error: use of undeclared identifier 'x' | |
| 13 | // :5:5: error: use of undeclared identifier 'x' |
test/cases/compile_errors/dont_implicit_cast_double_pointer_to_anyopaque.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry() void { | |
| 2 | var a: u32 = 1; | |
| 3 | var ptr: *align(@alignOf(u32)) anyopaque = &a; | |
| 4 | var b: *u32 = @ptrCast(*u32, ptr); | |
| 5 | var ptr2: *anyopaque = &b; | |
| 6 | _ = ptr2; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :5:28: error: expected type '*anyopaque', found '**u32' |
test/cases/compile_errors/duplicate_boolean_switch_value.zig created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | comptime { | |
| 2 | const x = switch (true) { | |
| 3 | true => false, | |
| 4 | false => true, | |
| 5 | true => false, | |
| 6 | }; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | comptime { | |
| 10 | const x = switch (true) { | |
| 11 | false => true, | |
| 12 | true => false, | |
| 13 | false => true, | |
| 14 | }; | |
| 15 | _ = x; | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage2 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // :5:9: error: duplicate switch value | |
| 23 | // :13:9: error: duplicate switch value |
test/cases/compile_errors/duplicate_error_value_in_error_set.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const Foo = error { | |
| 2 | Bar, | |
| 3 | Bar, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const a: Foo = undefined; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :3:5: error: duplicate error set field 'Bar' | |
| 15 | // :2:5: note: previous declaration here |
test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | const A = struct { | |
| 2 | x : i32, | |
| 3 | y : i32, | |
| 4 | z : i32, | |
| 5 | }; | |
| 6 | export fn f() void { | |
| 7 | const a = A { | |
| 8 | .z = 1, | |
| 9 | .y = 2, | |
| 10 | .x = 3, | |
| 11 | .z = 4, | |
| 12 | }; | |
| 13 | _ = a; | |
| 14 | } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage2 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // :11:10: error: duplicate field | |
| 21 | // :8:10: note: other field here |
test/cases/compile_errors/duplicate_struct_field.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const Foo = struct { | |
| 2 | Bar: i32, | |
| 3 | Bar: usize, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const a: Foo = undefined; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :3:5: error: duplicate struct field: 'Bar' | |
| 15 | // :2:5: note: other field here | |
| 16 | // :1:13: note: struct declared here |
test/cases/compile_errors/duplicate_union_field.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const Foo = union { | |
| 2 | Bar: i32, | |
| 3 | Bar: usize, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const a: Foo = undefined; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :3:5: error: duplicate union field: 'Bar' | |
| 15 | // :2:5: note: other field here | |
| 16 | // :1:13: note: union declared here |
test/cases/compile_errors/embedFile_with_bogus_file.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const resource = @embedFile("bogus.txt",); | |
| 2 | ||
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(resource)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :1:29: error: unable to open 'bogus.txt': FileNotFound |
test/cases/compile_errors/empty_for_loop_body.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a() void { | |
| 2 | for(undefined) |x|; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:23: error: expected block or assignment, found ';' |
test/cases/compile_errors/empty_if_body.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a() void { | |
| 2 | if(true); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:13: error: expected block or assignment, found ';' |
test/cases/compile_errors/empty_switch_on_an_integer.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: u32 = 0; | |
| 3 | switch(x) {} | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:5: error: switch must handle all possibilities |
test/cases/compile_errors/empty_while_loop_body.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a() void { | |
| 2 | while(true); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:16: error: expected block or assignment, found ';' |
test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const Foo = enum(u32) { | |
| 2 | A = 10, | |
| 3 | B = 11, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | var x = @intToEnum(Foo, 0); | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :6:13: error: enum 'tmp.Foo' has no tag with value '0' | |
| 15 | // :1:13: note: enum declared here |
test/cases/compile_errors/enum_with_0_fields.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | const Foo = enum {}; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:13: error: enum declarations must have at least one tag |
test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(@typeInfo(enum { foo, const bar = 1; })); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:9: error: reified enums must have no decls |
test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | pub export fn entry() void { | |
| 2 | const bitfield = struct { | |
| 3 | e: u8, | |
| 4 | e: u8, | |
| 5 | }; | |
| 6 | var a = .{@sizeOf(bitfield)}; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :4:9: error: duplicate struct field: 'e' | |
| 15 | // :3:9: note: other field here | |
| 16 | // :2:22: note: struct declared here |
test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | comptime { | |
| 2 | const z = i32!i32; | |
| 3 | var x: z = undefined; | |
| 4 | _ = x; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:15: error: expected error set type, found 'i32' |
test/cases/compile_errors/errors_in_for_loop_bodies_are_propagated.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var arr: [100]u8 = undefined; | |
| 3 | for (arr) |bits| _ = @popCount(bits); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:26: error: expected 2 arguments, found 1 |
test/cases/compile_errors/exceeded_maximum_bit_width_of_integer.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | export fn entry1() void { | |
| 2 | const T = u65536; | |
| 3 | _ = T; | |
| 4 | } | |
| 5 | export fn entry2() void { | |
| 6 | var x: i65536 = 1; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=llvm | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :2:15: error: primitive integer type 'u65536' exceeds maximum bit width of 65535 | |
| 15 | // :6:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535 |
test/cases/compile_errors/explicit_cast_float_literal_to_integer_when_there_is_a_fraction_component.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() i32 { | |
| 2 | return @as(i32, 12.34); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:21: error: fractional component prevents float value '12.34' from coercion to type 'i32' |
test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const Set1 = error {A, B}; | |
| 2 | const Set2 = error {A, C}; | |
| 3 | comptime { | |
| 4 | var x = Set1.B; | |
| 5 | var y = @errSetCast(Set2, x); | |
| 6 | _ = y; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :5:13: error: 'error.B' not a member of error set 'error{A,C}' | |
| 14 | // :2:14: note: error set declared here |
test/cases/compile_errors/export_with_empty_name_string.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | pub export fn entry() void { } | |
| 2 | comptime { | |
| 3 | @export(entry, .{ .name = "" }); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=llvm | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:21: error: exported symbol name cannot be empty |
test/cases/compile_errors/extern_union_field_missing_type.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Letter = extern union { | |
| 2 | A, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var a = Letter { .A = {} }; | |
| 6 | _ = a; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :2:5: error: union field missing type |
test/cases/compile_errors/extern_variable_has_no_type.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | extern var foo; | |
| 2 | pub export fn entry() void { | |
| 3 | foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :1:8: error: unable to infer variable type |
test/cases/compile_errors/fieldParentPtr-bad_field_name.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Foo = extern struct { | |
| 2 | derp: i32, | |
| 3 | }; | |
| 4 | export fn foo(a: *i32) *Foo { | |
| 5 | return @fieldParentPtr(Foo, "a", a); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :5:33: error: no field named 'a' in struct 'tmp.Foo' | |
| 13 | // :1:20: note: struct declared here |
test/cases/compile_errors/fieldParentPtr-non_struct.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const Foo = i32; | |
| 2 | export fn foo(a: *i32) *Foo { | |
| 3 | return @fieldParentPtr(Foo, "a", a); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=llvm | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:28: error: expected struct type, found 'i32' |
test/cases/compile_errors/field_type_supplied_in_an_enum.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const Letter = enum { | |
| 2 | A: void, | |
| 3 | B, | |
| 4 | C, | |
| 5 | }; | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:8: error: enum fields do not have types | |
| 12 | // :1:16: note: consider 'union(enum)' here to make it a tagged union |
test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry() void { | |
| 2 | var arr: [4]f32 = undefined; | |
| 3 | arr = concat(); | |
| 4 | } | |
| 5 | fn concat() [16]f32 { | |
| 6 | return [1]f32{0}**16; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=llvm | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :3:17: error: expected type '[4]f32', found '[16]f32' |
test/cases/compile_errors/function_prototype_with_no_body.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn foo() void; | |
| 2 | export fn entry() void { | |
| 3 | foo(); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=llvm | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :1:1: error: non-extern function has no body |
test/cases/compile_errors/function_with_invalid_return_type.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | export fn foo() boid {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:17: error: use of undeclared identifier 'boid' |
test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var res: []i32 = undefined; | |
| 3 | res = myAlloc(i32); | |
| 4 | } | |
| 5 | fn myAlloc(comptime arg: type) anyerror!arg{ | |
| 6 | unreachable; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :3:18: error: expected type '[]i32', found 'anyerror!i32' |
test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | extern fn foo() i32; | |
| 2 | const x = foo(); | |
| 3 | export fn entry() i32 { return x; } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:14: error: comptime call of extern function |
test/cases/compile_errors/hasDecl_with_non-container.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @hasDecl(i32, "hi"); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:18: error: expected struct, enum, union, or opaque; found 'i32' |
test/cases/compile_errors/if_condition_is_bool_not_int.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn f() void { | |
| 2 | if (0) {} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:9: error: expected type 'bool', found 'comptime_int' |
test/cases/compile_errors/ignored_assert-err-ok_return_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn foo() void { | |
| 2 | bar() catch unreachable; | |
| 3 | } | |
| 4 | fn bar() anyerror!i32 { return 0; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:11: error: expression value is ignored |
test/cases/compile_errors/ignored_comptime_statement_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn foo() void { | |
| 2 | comptime {1;} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:15: error: expression value is ignored |
test/cases/compile_errors/ignored_comptime_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn foo() void { | |
| 2 | comptime 1; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: expression value is ignored |
test/cases/compile_errors/ignored_deferred_statement_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn foo() void { | |
| 2 | defer {1;} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:12: error: expression value is ignored |
test/cases/compile_errors/ignored_return_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn foo() void { | |
| 2 | bar(); | |
| 3 | } | |
| 4 | fn bar() i32 { return 0; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:8: error: expression value is ignored |
test/cases/compile_errors/ignored_statement_value.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn foo() void { | |
| 2 | 1; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: expression value is ignored |
test/cases/compile_errors/implicit_semicolon-block_expr.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = {}; | |
| 3 | var good = {}; | |
| 4 | _ = {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:11: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-block_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | {} | |
| 3 | var good = {}; | |
| 4 | ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:9: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-comptime_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = comptime {}; | |
| 3 | var good = {}; | |
| 4 | _ = comptime {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:20: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-comptime_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | comptime {} | |
| 3 | var good = {}; | |
| 4 | comptime ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:18: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-defer.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | defer {} | |
| 3 | var good = {}; | |
| 4 | defer ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:15: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-for_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = for(foo()) |_| {}; | |
| 3 | var good = {}; | |
| 4 | _ = for(foo()) |_| {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:26: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-for_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | for(foo()) |_| {} | |
| 3 | var good = {}; | |
| 4 | for(foo()) |_| ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:24: error: expected ';' or 'else' after statement |
test/cases/compile_errors/implicit_semicolon-if-else-if-else_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {} else if(true) {} else {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} else if(true) {} else {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:45: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-if-else-if-else_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} else if(true) {} else {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) else if(true) ({}) else ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:47: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-if-else-if_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {} else if(true) {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} else if(true) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:37: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-if-else-if_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} else if(true) {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) else if(true) ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:37: error: expected ';' or 'else' after statement |
test/cases/compile_errors/implicit_semicolon-if-else_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {} else {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} else {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:28: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-if-else_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} else {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) else ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:28: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-if_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:20: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-if_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:18: error: expected ';' or 'else' after statement |
test/cases/compile_errors/implicit_semicolon-test_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if (foo()) |_| {}; | |
| 3 | var good = {}; | |
| 4 | _ = if (foo()) |_| {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:26: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-test_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | if (foo()) |_| {} | |
| 3 | var good = {}; | |
| 4 | if (foo()) |_| ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:24: error: expected ';' or 'else' after statement |
test/cases/compile_errors/implicit_semicolon-while-continue_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = while(true):({}) {}; | |
| 3 | var good = {}; | |
| 4 | _ = while(true):({}) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:28: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-while-continue_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | while(true):({}) {} | |
| 3 | var good = {}; | |
| 4 | while(true):({}) ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:26: error: expected ';' or 'else' after statement |
test/cases/compile_errors/implicit_semicolon-while_expression.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = while(true) {}; | |
| 3 | var good = {}; | |
| 4 | _ = while(true) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:23: error: expected ';' after statement |
test/cases/compile_errors/implicit_semicolon-while_statement.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn entry() void { | |
| 2 | while(true) {} | |
| 3 | var good = {}; | |
| 4 | while(true) 1 | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:18: error: expected ';' or 'else' after statement |
test/cases/compile_errors/import_outside_package_path.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | comptime{ | |
| 2 | _ = @import("../a.zig"); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:17: error: import of file outside package path: '../a.zig' |
test/cases/compile_errors/inferred_array_size_invalid_here.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = [_]u8; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | export fn entry2() void { | |
| 6 | const S = struct { a: *const [_]u8 }; | |
| 7 | var a = .{ S{} }; | |
| 8 | _ = a; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage2 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // :2:16: error: unable to infer array size | |
| 16 | // :6:35: error: unable to infer array size |
test/cases/compile_errors/inferring_error_set_of_function_pointer.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | comptime { | |
| 2 | const z: ?fn()!void = null; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:19: error: function prototype may not have inferred error set |
test/cases/compile_errors/initializing_array_with_struct_syntax.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = [_]u8{ .y = 2 }; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:15: error: initializing array with struct syntax |
test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: f32 = 2; | |
| 3 | _ = @floatToInt(comptime_int, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var a: u32 = 2; | |
| 7 | _ = @intToFloat(comptime_float, a); | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :3:35: error: unable to resolve comptime value | |
| 15 | // :7:37: error: unable to resolve comptime value |
test/cases/compile_errors/int_to_err_global_invalid_number.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const Set1 = error{ | |
| 2 | A, | |
| 3 | B, | |
| 4 | }; | |
| 5 | comptime { | |
| 6 | var x: u16 = 3; | |
| 7 | var y = @intToError(x); | |
| 8 | _ = y; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage2 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // :7:25: error: integer value '3' represents no error |
test/cases/compile_errors/int_to_err_non_global_invalid_number.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | const Set1 = error{ | |
| 2 | A, | |
| 3 | B, | |
| 4 | }; | |
| 5 | const Set2 = error{ | |
| 6 | A, | |
| 7 | C, | |
| 8 | }; | |
| 9 | comptime { | |
| 10 | var x = @errorToInt(Set1.B); | |
| 11 | var y = @errSetCast(Set2, @intToError(x)); | |
| 12 | _ = y; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=llvm | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // :11:13: error: 'error.B' not a member of error set 'error{A,C}' | |
| 20 | // :5:14: note: error set declared here |
test/cases/compile_errors/integer_overflow_error.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | const x : u8 = 300; | |
| 2 | export fn entry() usize { return @sizeOf(@TypeOf(x)); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :1:16: error: type 'u8' cannot represent integer value '300' |
test/cases/compile_errors/integer_underflow_error.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @intToPtr(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:78: error: overflow of integer type 'usize' with value '-1' |
test/cases/compile_errors/invalid_address_space_coercion.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | fn entry(a: *addrspace(.gs) i32) *i32 { | |
| 2 | return a; | |
| 3 | } | |
| 4 | pub fn main() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Exe | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:12: error: expected type '*i32', found '*addrspace(.gs) i32' |
test/cases/compile_errors/invalid_array_elem_ty.zig+1-1| ... | ... | @@ -9,4 +9,4 @@ pub export fn entry() void { |
| 9 | 9 | // target=native |
| 10 | 10 | // backend=stage2 |
| 11 | 11 | // |
| 12 | // :4:1: error: expected type, found fn() type | |
| 12 | // :4:1: error: expected type 'type', found 'fn() type' |
test/cases/compile_errors/invalid_assignments.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | export fn entry1() void { | |
| 2 | var a: []const u8 = "foo"; | |
| 3 | a[0..2] = "bar"; | |
| 4 | } | |
| 5 | export fn entry2() void { | |
| 6 | var a: u8 = 2; | |
| 7 | a + 2 = 3; | |
| 8 | } | |
| 9 | export fn entry4() void { | |
| 10 | 2 + 2 = 3; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :3:6: error: invalid left-hand side to assignment | |
| 18 | // :7:7: error: invalid left-hand side to assignment | |
| 19 | // :10:7: error: invalid left-hand side to assignment |
test/cases/compile_errors/invalid_break_expression.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn f() void { | |
| 2 | break; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: break expression outside loop |
test/cases/compile_errors/invalid_builtin_fn.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | fn f() @bogus(foo) { | |
| 2 | } | |
| 3 | export fn entry() void { _ = f(); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :1:8: error: invalid builtin function: '@bogus' |
test/cases/compile_errors/invalid_comparison_for_function_pointers.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn foo() void {} | |
| 2 | const invalid = foo > foo; | |
| 3 | ||
| 4 | export fn entry() usize { return @sizeOf(@TypeOf(invalid)); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: operator > not allowed for type 'fn() void' |
test/cases/compile_errors/invalid_continue_expression.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn f() void { | |
| 2 | continue; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: continue expression outside loop |
test/cases/compile_errors/invalid_empty_unicode_escape.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | const a = '\u{}'; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:19: error: empty unicode escape sequence |
test/cases/compile_errors/invalid_exponent_in_float_literal-1.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x1.0p1ab1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:28: note: invalid byte: 'a' |
test/cases/compile_errors/invalid_exponent_in_float_literal-2.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x1.0p50F; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:29: note: invalid byte: 'F' |
test/cases/compile_errors/invalid_field_access_in_comptime.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | comptime { var x = doesnt_exist.whatever; _ = x; } | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:20: error: use of undeclared identifier 'doesnt_exist' |
test/cases/compile_errors/invalid_field_in_struct_value_expression.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | const A = struct { | |
| 2 | x : i32, | |
| 3 | y : i32, | |
| 4 | z : i32, | |
| 5 | }; | |
| 6 | export fn f() void { | |
| 7 | const a = A { | |
| 8 | .z = 4, | |
| 9 | .y = 2, | |
| 10 | .foo = 42, | |
| 11 | }; | |
| 12 | _ = a; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage2 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // :10:10: error: no field named 'foo' in struct 'tmp.A' | |
| 20 | // :1:11: note: struct declared here |
test/cases/compile_errors/invalid_float_casts.zig created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: f32 = 2; | |
| 3 | _ = @floatCast(comptime_float, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var a: f32 = 2; | |
| 7 | _ = @floatToInt(f32, a); | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | var a: f32 = 2; | |
| 11 | _ = @intToFloat(f32, a); | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | var a: u32 = 2; | |
| 15 | _ = @floatCast(f32, a); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage2 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // :3:36: error: unable to cast runtime value to 'comptime_float' | |
| 23 | // :7:21: error: expected integer type, found 'f32' | |
| 24 | // :11:26: error: expected integer type, found 'f32' | |
| 25 | // :15:25: error: expected float type, found 'u32' |
test/cases/compile_errors/invalid_float_literal.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var bad_float :f32 = 0.0; | |
| 5 | bad_float = bad_float + .20; | |
| 6 | std.debug.assert(bad_float < 1.0); | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :5:29: error: expected expression, found '.' |
test/cases/compile_errors/invalid_int_casts.zig created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: u32 = 2; | |
| 3 | _ = @intCast(comptime_int, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var a: u32 = 2; | |
| 7 | _ = @intToFloat(u32, a); | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | var a: u32 = 2; | |
| 11 | _ = @floatToInt(u32, a); | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | var a: f32 = 2; | |
| 15 | _ = @intCast(u32, a); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage2 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // :3:32: error: unable to cast runtime value to 'comptime_int' | |
| 23 | // :7:21: error: expected float type, found 'u32' | |
| 24 | // :11:26: error: expected float type, found 'u32' | |
| 25 | // :15:23: error: expected integer or vector, found 'f32' |
test/cases/compile_errors/invalid_legacy_unicode_escape.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const a = '\U1234'; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:15: error: expected expression, found 'invalid bytes' | |
| 10 | // :2:18: note: invalid byte: '1' |
test/cases/compile_errors/invalid_member_of_builtin_enum.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const builtin = @import("std").builtin; | |
| 2 | export fn entry() void { | |
| 3 | const foo = builtin.Mode.x86; | |
| 4 | _ = foo; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:30: error: enum 'builtin.Mode' has no member named 'x86' | |
| 12 | // :?:18: note: enum declared here |
test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | const E = enum(u8) { | |
| 2 | a, | |
| 3 | b, | |
| 4 | _, | |
| 5 | }; | |
| 6 | const U = union(E) { | |
| 7 | a, | |
| 8 | b, | |
| 9 | }; | |
| 10 | export fn foo() void { | |
| 11 | var e = @intToEnum(E, 15); | |
| 12 | var u: U = e; | |
| 13 | _ = u; | |
| 14 | } | |
| 15 | export fn bar() void { | |
| 16 | const e = @intToEnum(E, 15); | |
| 17 | var u: U = e; | |
| 18 | _ = u; | |
| 19 | } | |
| 20 | ||
| 21 | // error | |
| 22 | // backend=stage2 | |
| 23 | // target=native | |
| 24 | // | |
| 25 | // :12:16: error: runtime coercion to union 'tmp.U' from non-exhaustive enum | |
| 26 | // :1:11: note: enum declared here | |
| 27 | // :17:16: error: union 'tmp.U' has no tag with value '15' | |
| 28 | // :6:11: note: union declared here |
test/cases/compile_errors/invalid_pointer_for_var_type.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | extern fn ext() usize; | |
| 2 | var bytes: [ext()]u8 = undefined; | |
| 3 | export fn f() void { | |
| 4 | for (bytes) |*b, i| { | |
| 5 | b.* = @as(u8, i); | |
| 6 | } | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :2:16: error: comptime call of extern function |
test/cases/compile_errors/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | fn entry(a: *addrspace(.gs) i32) *i32 { | |
| 2 | return &a.*; | |
| 3 | } | |
| 4 | pub fn main() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Exe | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:12: error: expected type '*i32', found '*addrspace(.gs) i32' |
test/cases/compile_errors/invalid_pointer_syntax.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn foo() void { | |
| 2 | var guid: *:0 const u8 = undefined; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:16: error: expected type expression, found ':' |
test/cases/compile_errors/invalid_pointer_with_reify_type.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(.{ .Pointer = .{ | |
| 3 | .size = .One, | |
| 4 | .is_const = false, | |
| 5 | .is_volatile = false, | |
| 6 | .alignment = 1, | |
| 7 | .address_space = .generic, | |
| 8 | .child = u8, | |
| 9 | .is_allowzero = false, | |
| 10 | .sentinel = &@as(u8, 0), | |
| 11 | }}); | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // :2:9: error: sentinels are only allowed on slices and unknown-length pointers |
test/cases/compile_errors/invalid_shift_amount_error.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const x : u8 = 2; | |
| 2 | fn f() u16 { | |
| 3 | return x << 8; | |
| 4 | } | |
| 5 | export fn entry() u16 { return f(); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:17: error: type 'u3' cannot represent integer value '8' |
test/cases/compile_errors/invalid_struct_field.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | const A = struct { x : i32, }; | |
| 2 | export fn f() void { | |
| 3 | var a : A = undefined; | |
| 4 | a.foo = 1; | |
| 5 | const y = a.bar; | |
| 6 | _ = y; | |
| 7 | } | |
| 8 | export fn g() void { | |
| 9 | var a : A = undefined; | |
| 10 | const y = a.bar; | |
| 11 | _ = y; | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // :4:7: error: no field named 'foo' in struct 'tmp.A' | |
| 19 | // :1:11: note: struct declared here | |
| 20 | // :10:17: error: no field named 'bar' in struct 'tmp.A' | |
| 21 |
test/cases/compile_errors/invalid_type.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | fn a() bogus {} | |
| 2 | export fn entry() void { _ = a(); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :1:8: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/invalid_type_used_in_array_type.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const Item = struct { | |
| 2 | field: SomeNonexistentType, | |
| 3 | }; | |
| 4 | var items: [100]Item = undefined; | |
| 5 | export fn entry() void { | |
| 6 | const a = items[0]; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :2:12: error: use of undeclared identifier 'SomeNonexistentType' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-1.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0._0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:23: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-10.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0__0e-1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:25: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-11.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e-1__0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:28: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-12.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0_x0.0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:23: note: invalid byte: 'x' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-13.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x_0.0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:23: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-14.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x0.0_p1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:27: note: invalid byte: 'p' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-2.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0_.0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:23: note: invalid byte: '.' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-3.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0.0_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:25: note: invalid byte: ';' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-4.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e_1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:25: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-5.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e+_1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:26: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-6.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e-_1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:26: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-7.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e-1_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:28: note: invalid byte: ';' |
test/cases/compile_errors/invalid_underscore_placement_in_float_literal-9.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1__0.0e-1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:23: note: invalid byte: '_' |
test/cases/compile_errors/invalid_underscore_placement_in_int_literal-1.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=llvm | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:26: note: invalid byte: ';' |
test/cases/compile_errors/invalid_underscore_placement_in_int_literal-2.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0b0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:28: note: invalid byte: ';' |
test/cases/compile_errors/invalid_underscore_placement_in_int_literal-3.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0o0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:28: note: invalid byte: ';' |
test/cases/compile_errors/invalid_underscore_placement_in_int_literal-4.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0x0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // :2:28: note: invalid byte: ';' |
test/cases/compile_errors/issue_9346_return_outside_of_function_scope.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | pub const empty = return 1; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:19: error: 'return' outside function scope |
test/cases/compile_errors/labeled_break_not_found.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry() void { | |
| 2 | blah: while (true) { | |
| 3 | while (true) { | |
| 4 | break :outer; | |
| 5 | } | |
| 6 | } | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :4:20: error: label not found: 'outer' |
test/cases/compile_errors/labeled_continue_not_found.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | export fn entry() void { | |
| 2 | var i: usize = 0; | |
| 3 | blah: while (i < 10) : (i += 1) { | |
| 4 | while (true) { | |
| 5 | continue :outer; | |
| 6 | } | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :5:23: error: label not found: 'outer' |
test/cases/compile_errors/local_shadows_global_that_occurs_later.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() void { | |
| 2 | var foo = true; | |
| 3 | _ = foo; | |
| 4 | } | |
| 5 | fn foo() void {} | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:9: error: local shadows declaration of 'foo' | |
| 12 | // :5:1: note: declared here |
test/cases/compile_errors/local_variable_redeclaration.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn f() void { | |
| 2 | const a : i32 = 0; | |
| 3 | var a = 0; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:9: error: redeclaration of local constant 'a' | |
| 11 | // :2:11: note: previous declaration here |
test/cases/compile_errors/local_variable_redeclares_parameter.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn f(a : i32) void { | |
| 2 | const a = 0; | |
| 3 | } | |
| 4 | export fn entry() void { f(1); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:11: error: redeclaration of function parameter 'a' | |
| 11 | // :1:6: note: previous declaration here |
test/cases/compile_errors/local_variable_shadowing_global.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const Foo = struct {}; | |
| 2 | const Bar = struct {}; | |
| 3 | ||
| 4 | export fn entry() void { | |
| 5 | var Bar : i32 = undefined; | |
| 6 | _ = Bar; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :5:9: error: local shadows declaration of 'Bar' | |
| 14 | // :2:1: note: declared here |
test/cases/compile_errors/locally_shadowing_a_primitive_type.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn foo() void { | |
| 2 | const u8 = u16; | |
| 3 | const a: u8 = 300; | |
| 4 | _ = a; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:11: error: name shadows primitive 'u8' | |
| 12 | // :2:11: note: consider using @"u8" to disambiguate |
test/cases/compile_errors/main_function_with_bogus_args_type.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | pub fn main(args: [][]bogus) !void {_ = args;} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:23: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/main_missing_name.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | pub fn (main) void {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // output_mode=Exe | |
| 7 | // | |
| 8 | // :1:5: error: missing function name |
test/cases/compile_errors/missing_boolean_switch_value.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | comptime { | |
| 2 | const x = switch (true) { | |
| 3 | true => false, | |
| 4 | }; | |
| 5 | _ = x; | |
| 6 | } | |
| 7 | comptime { | |
| 8 | const x = switch (true) { | |
| 9 | false => true, | |
| 10 | }; | |
| 11 | _ = x; | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // :2:15: error: switch must handle all possibilities | |
| 19 | // :8:15: error: switch must handle all possibilities |
test/cases/compile_errors/missing_else_clause.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | fn f(b: bool) void { | |
| 2 | const x : i32 = if (b) h: { break :h 1; }; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | fn g(b: bool) void { | |
| 6 | const y = if (b) h: { break :h @as(i32, 1); }; | |
| 7 | _ = y; | |
| 8 | } | |
| 9 | export fn entry() void { f(true); g(true); } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage2 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // :2:21: error: incompatible types: 'i32' and 'void' | |
| 16 | // :6:15: error: incompatible types: 'i32' and 'void' |
test/cases/compile_errors/missing_field_in_struct_value_expression.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | const A = struct { | |
| 2 | x : i32, | |
| 3 | y : i32, | |
| 4 | z : i32, | |
| 5 | }; | |
| 6 | export fn f() void { | |
| 7 | // we want the error on the '{' not the 'A' because | |
| 8 | // the A could be a complicated expression | |
| 9 | const a = A { | |
| 10 | .z = 4, | |
| 11 | .y = 2, | |
| 12 | }; | |
| 13 | _ = a; | |
| 14 | } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage2 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // :9:17: error: missing struct field: x | |
| 21 | // :1:11: note: struct 'tmp.A' declared here |
test/cases/compile_errors/missing_function_name.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | fn () void {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:1: error: missing function name |
test/cases/compile_errors/missing_param_name.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | fn f(i32) void {} | |
| 2 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :1:6: error: missing parameter name |
test/cases/compile_errors/missing_parameter_name_of_generic_function.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn dump(anytype) void {} | |
| 2 | export fn entry() void { | |
| 3 | var a: u8 = 9; | |
| 4 | dump(a); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :1:9: error: missing parameter name |
test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | const JasonHM = u8; | |
| 2 | const JasonList = *JsonNode; | |
| 3 | ||
| 4 | const JsonOA = union(enum) { | |
| 5 | JSONArray: JsonList, | |
| 6 | JSONObject: JasonHM, | |
| 7 | }; | |
| 8 | ||
| 9 | const JsonType = union(enum) { | |
| 10 | JSONNull: void, | |
| 11 | JSONInteger: isize, | |
| 12 | JSONDouble: f64, | |
| 13 | JSONBool: bool, | |
| 14 | JSONString: []u8, | |
| 15 | JSONArray: void, | |
| 16 | JSONObject: void, | |
| 17 | }; | |
| 18 | ||
| 19 | pub const JsonNode = struct { | |
| 20 | kind: JsonType, | |
| 21 | jobject: ?JsonOA, | |
| 22 | }; | |
| 23 | ||
| 24 | fn foo() void { | |
| 25 | var jll: JasonList = undefined; | |
| 26 | jll.init(1234); | |
| 27 | var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} }; | |
| 28 | _ = jd; | |
| 29 | } | |
| 30 | ||
| 31 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 32 | ||
| 33 | // error | |
| 34 | // backend=stage2 | |
| 35 | // target=native | |
| 36 | // | |
| 37 | // :5:16: error: use of undeclared identifier 'JsonList' |
test/cases/compile_errors/multiple_function_definitions.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn a() void {} | |
| 2 | fn a() void {} | |
| 3 | export fn entry() void { a(); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:1: error: redeclaration of 'a' | |
| 10 | // :1:1: note: other declaration here |
test/cases/compile_errors/nested_vectors.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry() void { | |
| 2 | const V1 = @import("std").meta.Vector(4, u8); | |
| 3 | const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } }); | |
| 4 | var v: V2 = undefined; | |
| 5 | _ = v; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :3:16: error: expected integer, float, bool, or pointer for the vector element type; found '@Vector(4, u8)' | |
| 13 |
test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | const Foo = struct { | |
| 2 | x: i32, | |
| 3 | }; | |
| 4 | const a = get_it(); | |
| 5 | fn get_it() Foo { | |
| 6 | global_side_effect = true; | |
| 7 | return Foo {.x = 13}; | |
| 8 | } | |
| 9 | var global_side_effect = false; | |
| 10 | ||
| 11 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :6:26: error: unable to resolve comptime value | |
| 18 | // :4:17: note: called from here |
test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Foo = struct { | |
| 2 | x: i32, | |
| 3 | }; | |
| 4 | const a = Foo {.x = get_it()}; | |
| 5 | extern fn get_it() i32; | |
| 6 | ||
| 7 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :4:27: error: comptime call of extern function |
test/cases/compile_errors/non-const_switch_number_literal.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | export fn foo() void { | |
| 2 | const x = switch (bar()) { | |
| 3 | 1, 2 => 1, | |
| 4 | 3, 4 => 2, | |
| 5 | else => 3, | |
| 6 | }; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | fn bar() i32 { | |
| 10 | return 2; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :2:15: error: value with comptime only type 'comptime_int' depends on runtime control flow | |
| 18 | // :2:26: note: runtime control flow here |
test/cases/compile_errors/non-exhaustive_enum_field_non_final.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const B = enum(u1) { | |
| 2 | a, | |
| 3 | _, | |
| 4 | b, | |
| 5 | }; | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:5: error: '_' field of non-exhaustive enum must be last |
test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | const A = enum { | |
| 2 | a, | |
| 3 | b, | |
| 4 | _ = 1, | |
| 5 | }; | |
| 6 | const B = enum { | |
| 7 | a, | |
| 8 | b, | |
| 9 | _, | |
| 10 | }; | |
| 11 | comptime { _ = A; _ = B; } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :4:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value | |
| 18 | // :6:11: error: non-exhaustive enum missing integer tag type | |
| 19 | // :9:5: note: marked non-exhaustive here |
test/cases/compile_errors/non-exhaustive_enum_specifies_every_value.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const C = enum(u1) { | |
| 2 | a, | |
| 3 | b, | |
| 4 | _, | |
| 5 | }; | |
| 6 | pub export fn entry() void { | |
| 7 | _ = C; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :1:11: error: non-exhaustive enum specifies every value |
test/cases/compile_errors/non-extern_function_with_var_args.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn foo(args: ...) void {} | |
| 2 | export fn entry() void { | |
| 3 | foo(); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :1:14: error: expected type expression, found '...' |
test/cases/compile_errors/non-pure_function_returns_type.zig created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | var a: u32 = 0; | |
| 2 | pub fn List(comptime T: type) type { | |
| 3 | a += 1; | |
| 4 | return SmallList(T, 8); | |
| 5 | } | |
| 6 | ||
| 7 | pub fn SmallList(comptime T: type, comptime STATIC_SIZE: usize) type { | |
| 8 | return struct { | |
| 9 | items: []T, | |
| 10 | length: usize, | |
| 11 | prealloc_items: [STATIC_SIZE]T, | |
| 12 | }; | |
| 13 | } | |
| 14 | ||
| 15 | export fn function_with_return_type_type() void { | |
| 16 | var list: List(i32) = undefined; | |
| 17 | list.length = 10; | |
| 18 | } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage2 | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // :3:7: error: unable to resolve comptime value | |
| 25 | // :16:19: note: called from here |
test/cases/compile_errors/non_float_passed_to_floatToInt.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @floatToInt(i32, @as(i32, 54)); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:32: error: expected float type, found 'i32' |
test/cases/compile_errors/non_int_passed_to_intToFloat.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @intToFloat(f32, 1.1); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:32: error: expected integer type, found 'comptime_float' |
test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry(x: i32) usize { | |
| 2 | return @ptrToInt(x); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:22: error: expected pointer, found 'i32' |
test/cases/compile_errors/normal_string_with_newline.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const foo = "a | |
| 2 | b"; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :1:13: error: expected expression, found 'invalid bytes' | |
| 9 | // :1:15: note: invalid byte: '\n' |
test/cases/compile_errors/not_an_enum_type.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | export fn entry() void { | |
| 2 | var self: Error = undefined; | |
| 3 | switch (self) { | |
| 4 | InvalidToken => |x| return x.token, | |
| 5 | ExpectedVarDeclOrFn => |x| return x.token, | |
| 6 | } | |
| 7 | } | |
| 8 | const Error = union(enum) { | |
| 9 | A: InvalidToken, | |
| 10 | B: ExpectedVarDeclOrFn, | |
| 11 | }; | |
| 12 | const InvalidToken = struct {}; | |
| 13 | const ExpectedVarDeclOrFn = struct {}; | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage2 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // :4:9: error: expected type '@typeInfo(tmp.Error).Union.tag_type.?', found 'type' |
test/cases/compile_errors/offsetOf-bad_field_name.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Foo = struct { | |
| 2 | derp: i32, | |
| 3 | }; | |
| 4 | export fn foo() usize { | |
| 5 | return @offsetOf(Foo, "a",); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :5:27: error: struct 'tmp.Foo' has no field 'a' | |
| 13 | // :1:13: note: struct declared here |
test/cases/compile_errors/offsetOf-non_struct.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const Foo = i32; | |
| 2 | export fn foo() usize { | |
| 3 | return @offsetOf(Foo, "a",); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:22: error: expected struct type, found 'i32' |
test/cases/compile_errors/only_equality_binary_operator_allowed_for_error_sets.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | const z = error.A > error.B; | |
| 3 | _ = z; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:23: error: operator > not allowed for type 'error{A,B}' |
test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @floatToInt(i8, 200); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:31: error: float value '200' cannot be stored in integer type 'i8' |
test/cases/compile_errors/parameter_redeclaration.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn f(a : i32, a : i32) void { | |
| 2 | } | |
| 3 | export fn entry() void { f(1, 2); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :1:15: error: redeclaration of function parameter 'a' | |
| 10 | // :1:6: note: previous declaration here |
test/cases/compile_errors/parameter_shadowing_global.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const Foo = struct {}; | |
| 2 | fn f(Foo: i32) void {} | |
| 3 | export fn entry() void { | |
| 4 | f(1234); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:6: error: local shadows declaration of 'Foo' | |
| 12 | // :1:1: note: declared here |
test/cases/compile_errors/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; | |
| 2 | export fn entry() bool { | |
| 3 | var x: i32 align(1) = 1234; | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) {} | |
| 5 | return x == 5678; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:31: error: expected type '*i32', found '*align(1) i32' |
test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | export fn foo() void { | |
| 2 | var x: [10]u8 = undefined; | |
| 3 | var y = &x; | |
| 4 | var z = y + 1; | |
| 5 | _ = z; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:15: error: incompatible types: '*[10]u8' and 'comptime_int' | |
| 13 | // :4:13: note: type '*[10]u8' here | |
| 14 | // :4:17: note: type 'comptime_int' here |
test/cases/compile_errors/pointer_with_different_address_spaces.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | fn entry(a: *addrspace(.gs) i32) *addrspace(.fs) i32 { | |
| 2 | return a; | |
| 3 | } | |
| 4 | export fn entry2() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Obj | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:12: error: expected type '*addrspace(.fs) i32', found '*addrspace(.gs) i32' |
test/cases/compile_errors/pointers_with_different_address_spaces.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | fn entry(a: ?*addrspace(.gs) i32) *i32 { | |
| 2 | return a.?; | |
| 3 | } | |
| 4 | pub fn main() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Exe | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:13: error: expected type '*i32', found '*addrspace(.gs) i32' |
test/cases/compile_errors/popCount-non-integer.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry(x: f32) u32 { | |
| 2 | return @popCount(f32, x); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:27: error: expected integer or vector, found 'f32' |
test/cases/compile_errors/primitives_take_precedence_over_declarations.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const @"u8" = u16; | |
| 2 | export fn entry() void { | |
| 3 | const a: u8 = 300; | |
| 4 | _ = a; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:19: error: type 'u8' cannot represent integer value '300' |
test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var b = @intToPtr(*i32, 0); | |
| 3 | _ = b; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:29: error: pointer type '*i32' does not allow address zero |
test/cases/compile_errors/ptrcast_to_non-pointer.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry(a: *i32) usize { | |
| 2 | return @ptrCast(usize, a); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=llvm | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:21: error: expected pointer type, found 'usize' |
test/cases/compile_errors/reassign_to_array_parameter.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | fn reassign(a: [3]f32) void { | |
| 2 | a = [3]f32{4, 5, 6}; | |
| 3 | } | |
| 4 | export fn entry() void { | |
| 5 | reassign(.{1, 2, 3}); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=llvm | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:15: error: cannot assign to constant |
test/cases/compile_errors/reassign_to_slice_parameter.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn reassign(s: []const u8) void { | |
| 2 | s = s[0..]; | |
| 3 | } | |
| 4 | export fn entry() void { | |
| 5 | reassign("foo"); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=llvm | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:10: error: cannot assign to constant |
test/cases/compile_errors/reassign_to_struct_parameter.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const S = struct { | |
| 2 | x: u32, | |
| 3 | }; | |
| 4 | fn reassign(s: S) void { | |
| 5 | s = S{.x = 2}; | |
| 6 | } | |
| 7 | export fn entry() void { | |
| 8 | reassign(S{.x = 3}); | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage2 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // :5:10: error: cannot assign to constant |
test/cases/compile_errors/redefinition_of_enums.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const A = enum {x}; | |
| 2 | const A = enum {x}; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :2:1: error: redeclaration of 'A' | |
| 9 | // :1:1: note: other declaration here |
test/cases/compile_errors/redefinition_of_global_variables.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | var a : i32 = 1; | |
| 2 | var a : i32 = 2; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :2:1: error: redeclaration of 'a' | |
| 9 | // :1:1: note: other declaration here |
test/cases/compile_errors/redefinition_of_struct.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const A = struct { x : i32, }; | |
| 2 | const A = struct { y : i32, }; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :2:1: error: redeclaration of 'A' | |
| 9 | // :1:1: note: other declaration here |
test/cases/compile_errors/refer_to_the_type_of_a_generic_function.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | const Func = fn (type) void; | |
| 3 | const f: Func = undefined; | |
| 4 | f(i32); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :4:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/reference_to_const_data.zig created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | export fn foo() void { | |
| 2 | var ptr = &[_]u8{0,0,0,0}; | |
| 3 | ptr[1] = 2; | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var ptr = &@as(u32, 2); | |
| 7 | ptr.* = 2; | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | var ptr = &true; | |
| 11 | ptr.* = false; | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | const S = struct{ | |
| 15 | x: usize, | |
| 16 | y: usize, | |
| 17 | }; | |
| 18 | var ptr = &S{.x=1,.y=2}; | |
| 19 | ptr.x = 2; | |
| 20 | } | |
| 21 | ||
| 22 | // error | |
| 23 | // backend=stage2 | |
| 24 | // target=native | |
| 25 | // | |
| 26 | // :3:14: error: cannot assign to constant | |
| 27 | // :7:13: error: cannot assign to constant | |
| 28 | // :11:13: error: cannot assign to constant | |
| 29 | // :19:13: error: cannot assign to constant |
test/cases/compile_errors/referring_to_a_struct_that_is_invalid.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | const UsbDeviceRequest = struct { | |
| 2 | Type: u8, | |
| 3 | }; | |
| 4 | ||
| 5 | export fn foo() void { | |
| 6 | comptime assert(@sizeOf(UsbDeviceRequest) == 0x8); | |
| 7 | } | |
| 8 | ||
| 9 | fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :10:14: error: reached unreachable code | |
| 18 | // :6:20: note: called from here |
test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn entry() void { | |
| 2 | var var_1: f32 = undefined; | |
| 3 | var var_2: u32 = undefined; | |
| 4 | _ = @TypeOf(var_1, var_2); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :4:9: error: incompatible types: 'f32' and 'u32' | |
| 12 | // :4:17: note: type 'f32' here | |
| 13 | // :4:24: note: type 'u32' here |
test/cases/compile_errors/reify_typeOf_with_no_arguments.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @TypeOf(); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:9: error: expected at least 1 argument, found 0 |
test/cases/compile_errors/reject_extern_function_definitions_with_body.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | extern "c" fn definitelyNotInLibC(a: i32, b: i32) i32 { | |
| 2 | return a + b; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :1:1: error: extern functions have no body |
test/cases/compile_errors/reject_extern_variables_with_initializers.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | extern var foo: int = 2; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:23: error: extern variables have no initializers |
test/cases/compile_errors/repeated_invalid_field_access_to_generic_function_returning_type_crashes_compiler_2655.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | pub fn A() type { | |
| 2 | return Q; | |
| 3 | } | |
| 4 | test "1" { | |
| 5 | _ = A().a; | |
| 6 | _ = A().a; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // is_test=1 | |
| 13 | // | |
| 14 | // :2:12: error: use of undeclared identifier 'Q' |
test/cases/compile_errors/return_from_defer_expression.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | pub fn testTrickyDefer() !void { | |
| 2 | defer canFail() catch {}; | |
| 3 | ||
| 4 | defer try canFail(); | |
| 5 | ||
| 6 | const a = maybeInt() orelse return; | |
| 7 | } | |
| 8 | ||
| 9 | fn canFail() anyerror!void { } | |
| 10 | ||
| 11 | pub fn maybeInt() ?i32 { | |
| 12 | return 0; | |
| 13 | } | |
| 14 | ||
| 15 | export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); } | |
| 16 | ||
| 17 | // error | |
| 18 | // backend=stage2 | |
| 19 | // target=native | |
| 20 | // | |
| 21 | // :4:11: error: 'try' not allowed inside defer expression |
test/cases/compile_errors/return_invalid_type_from_test.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | test "example" { return 1; } | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // is_test=1 | |
| 7 | // | |
| 8 | // :1:25: error: expected type 'void', found 'comptime_int' |
test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | const Letter = enum { A, B, C }; | |
| 2 | const Value = union(Letter) { | |
| 3 | A: i32, | |
| 4 | B, | |
| 5 | C, | |
| 6 | }; | |
| 7 | export fn entry() void { | |
| 8 | foo(Letter.A); | |
| 9 | } | |
| 10 | fn foo(l: Letter) void { | |
| 11 | var x: Value = l; | |
| 12 | _ = x; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage2 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // :11:20: error: runtime coercion from enum 'tmp.Letter' to union 'tmp.Value' which has non-void fields | |
| 20 | // :3:5: note: field 'A' has type 'i32' | |
| 21 | // :4:5: note: field 'B' has type 'void' | |
| 22 | // :5:5: note: field 'C' has type 'void' | |
| 23 | // :2:15: note: union declared here |
test/cases/compile_errors/saturating_arithmetic_does_not_allow_floats.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a() void { | |
| 2 | _ = @as(f32, 1.0) +| @as(f32, 1.0); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:23: error: invalid operands to binary expression: 'Float' and 'Float' |
test/cases/compile_errors/setAlignStack_in_naked_function.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() callconv(.Naked) void { | |
| 2 | @setAlignStack(16); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: @setAlignStack in naked function |
test/cases/compile_errors/setAlignStack_outside_function.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | comptime { | |
| 2 | @setAlignStack(16); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: @setAlignStack outside function body |
test/cases/compile_errors/setAlignStack_set_twice.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | @setAlignStack(16); | |
| 3 | @setAlignStack(16); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:5: error: multiple @setAlignStack in the same function body | |
| 11 | // :2:5: note: other instance here |
test/cases/compile_errors/setAlignStack_too_big.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | @setAlignStack(511 + 1); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: attempt to @setAlignStack(512); maximum is 256 |
test/cases/compile_errors/setting_a_section_on_a_local_variable.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() i32 { | |
| 2 | var foo: i32 linksection(".text2") = 1234; | |
| 3 | return foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:30: error: cannot set section of local variable 'foo' |
test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | export fn entry() void { | |
| 2 | const S = struct { | |
| 3 | fn a() void { | |
| 4 | var x: u24 = 42; | |
| 5 | _ = x >> 24; | |
| 6 | } | |
| 7 | fn b() void { | |
| 8 | var x: u24 = 42; | |
| 9 | _ = x << 24; | |
| 10 | } | |
| 11 | fn c() void { | |
| 12 | var x: u24 = 42; | |
| 13 | _ = @shlExact(x, 24); | |
| 14 | } | |
| 15 | fn d() void { | |
| 16 | var x: u24 = 42; | |
| 17 | _ = @shrExact(x, 24); | |
| 18 | } | |
| 19 | }; | |
| 20 | S.a(); | |
| 21 | S.b(); | |
| 22 | S.c(); | |
| 23 | S.d(); | |
| 24 | } | |
| 25 | ||
| 26 | // error | |
| 27 | // backend=stage2 | |
| 28 | // target=native | |
| 29 | // | |
| 30 | // :5:22: error: shift amount '24' is too large for operand type 'u24' | |
| 31 | // :9:22: error: shift amount '24' is too large for operand type 'u24' | |
| 32 | // :13:30: error: shift amount '24' is too large for operand type 'u24' | |
| 33 | // :17:30: error: shift amount '24' is too large for operand type 'u24' |
test/cases/compile_errors/shifting_RHS_is_log2_of_LHS_int_bit_width.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry(x: u8, y: u8) u8 { | |
| 2 | return x << y; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:17: error: expected type 'u3', found 'u8' |
test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | export fn entry() void { | |
| 2 | const v: @import("std").meta.Vector(4, u32) = [4]u32{ 10, 11, 12, 13 }; | |
| 3 | const x: @import("std").meta.Vector(4, u32) = [4]u32{ 14, 15, 16, 17 }; | |
| 4 | var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 }); | |
| 5 | _ = z; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :4:39: error: mask index '4' has out-of-bounds selection | |
| 13 | // :4:27: note: selected index '7' out of bounds of '@Vector(4, u32)' | |
| 14 | // :4:30: note: selections from the second vector are specified with negative numbers |
test/cases/compile_errors/slicing_single-item_pointer.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry(ptr: *i32) void { | |
| 2 | const slice = ptr[0..2]; | |
| 3 | _ = slice; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:22: error: slice of single-item pointer |
test/cases/compile_errors/stage1/add_wrap_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a +%= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/add_wrap_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a +% a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/alignCast_of_zero_sized_types.zig created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | export fn foo() void { | |
| 2 | const a: *void = undefined; | |
| 3 | _ = @alignCast(2, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | const a: ?*void = undefined; | |
| 7 | _ = @alignCast(2, a); | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | const a: []void = undefined; | |
| 11 | _ = @alignCast(2, a); | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | const a = struct { | |
| 15 | fn a(comptime b: u32) void { _ = b; } | |
| 16 | }.a; | |
| 17 | _ = @alignCast(2, a); | |
| 18 | } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage1 | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // tmp.zig:3:23: error: cannot adjust alignment of zero sized type '*void' | |
| 25 | // tmp.zig:7:23: error: cannot adjust alignment of zero sized type '?*void' | |
| 26 | // tmp.zig:11:23: error: cannot adjust alignment of zero sized type '[]void' | |
| 27 | // tmp.zig:17:23: error: cannot adjust alignment of zero sized type 'fn(u32) anytype' |
test/cases/compile_errors/stage1/and_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: bool = undefined; | |
| 3 | _ = a and a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_and_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a &= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_and_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a & a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_not_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = ~a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_or_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a |= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_or_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a | a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_xor_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a ^= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bin_xor_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a ^ a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/bool_not_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: bool = undefined; | |
| 3 | _ = !a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/catch_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: anyerror!bool = undefined; | |
| 3 | _ = a catch false; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/deref_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: *u8 = undefined; | |
| 3 | _ = a.*; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: attempt to dereference undefined value |
test/cases/compile_errors/stage1/div_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a /= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/div_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a / a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/exe/main_missing_name.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | pub fn (main) void {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // output_mode=Exe | |
| 7 | // | |
| 8 | // tmp.zig:1:5: error: missing function name |
test/cases/compile_errors/stage1/mod_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a %= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/mod_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a % a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/mult_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a *= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/mult_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a * a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/mult_wrap_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a *%= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/mult_wrap_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a *% a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/negate_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = -a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/negate_wrap_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = -%a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/Issue_5586_Make_unary_minus_for_unsigned_types_a_compile_error.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn f1(x: u32) u32 { | |
| 2 | const y = -%x; | |
| 3 | return -y; | |
| 4 | } | |
| 5 | const V = @import("std").meta.Vector; | |
| 6 | export fn f2(x: V(4, u32)) V(4, u32) { | |
| 7 | const y = -%x; | |
| 8 | return -y; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // tmp.zig:3:12: error: negation of type 'u32' | |
| 16 | // tmp.zig:8:12: error: negation of type 'u32' |
test/cases/compile_errors/stage1/obj/Issue_6823_dont_allow_._to_be_followed_by_.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn foo() void { | |
| 2 | var sequence = "repeat".*** 10; | |
| 3 | _ = sequence; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:28: error: '.*' cannot be followed by '*'. Are you missing a space? |
test/cases/compile_errors/stage1/obj/access_non-existent_member_of_error_set.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const Foo = error{A}; | |
| 2 | comptime { | |
| 3 | const z = Foo.Bar; | |
| 4 | _ = z; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:18: error: no error named 'Bar' in 'Foo' |
test/cases/compile_errors/stage1/obj/add_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a += a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/add_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a + a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/add_overflow_in_function_evaluation.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const y = add(65530, 10); | |
| 2 | fn add(a: u16, b: u16) u16 { | |
| 3 | return a + b; | |
| 4 | } | |
| 5 | ||
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(y)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:3:14: error: operation caused overflow |
test/cases/compile_errors/stage1/obj/add_wrap_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a +%= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/add_wrap_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a +% a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/addition_with_non_numbers.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | field: i32, | |
| 3 | }; | |
| 4 | const x = Foo {.field = 1} + Foo {.field = 2}; | |
| 5 | ||
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(x)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo' |
test/cases/compile_errors/stage1/obj/address_of_number_literal.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const x = 3; | |
| 2 | const y = &x; | |
| 3 | fn foo() *const i32 { return y; } | |
| 4 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:30: error: expected type '*const i32', found '*const comptime_int' |
test/cases/compile_errors/stage1/obj/alignCast_expects_pointer_or_slice.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | @alignCast(4, @as(u32, 3)); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:19: error: expected pointer or slice, found 'u32' |
test/cases/compile_errors/stage1/obj/alignment_of_enum_field_specified.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const Number = enum { | |
| 2 | a, | |
| 3 | b align(i32), | |
| 4 | }; | |
| 5 | export fn entry1() void { | |
| 6 | var x: Number = undefined; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:3:7: error: expected ',' after field |
test/cases/compile_errors/stage1/obj/ambiguous_decl_reference.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | fn foo() void {} | |
| 2 | fn bar() void { | |
| 3 | const S = struct { | |
| 4 | fn baz() void { | |
| 5 | foo(); | |
| 6 | } | |
| 7 | fn foo() void {} | |
| 8 | }; | |
| 9 | S.baz(); | |
| 10 | } | |
| 11 | export fn entry() void { | |
| 12 | bar(); | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage1 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // tmp.zig:5:13: error: ambiguous reference | |
| 20 | // tmp.zig:7:9: note: declared here | |
| 21 | // tmp.zig:1:1: note: also declared here |
test/cases/compile_errors/stage1/obj/and_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: bool = undefined; | |
| 3 | _ = a and a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/array_access_of_undeclared_identifier.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | i[i] = i[i]; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: use of undeclared identifier 'i' |
test/cases/compile_errors/stage1/obj/array_concatenation_with_wrong_type.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const src = "aoeu"; | |
| 2 | const derp: usize = 1234; | |
| 3 | const a = derp ++ "foo"; | |
| 4 | ||
| 5 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:11: error: expected array, found 'usize' |
test/cases/compile_errors/stage1/obj/asm_at_compile_time.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | comptime { | |
| 2 | doSomeAsm(); | |
| 3 | } | |
| 4 | ||
| 5 | fn doSomeAsm() void { | |
| 6 | asm volatile ( | |
| 7 | \\.globl aoeu; | |
| 8 | \\.type aoeu, @function; | |
| 9 | \\.set aoeu, derp; | |
| 10 | ); | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:6:5: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/obj/assign_inline_fn_to_non-comptime_var.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var a = b; | |
| 3 | _ = a; | |
| 4 | } | |
| 5 | fn b() callconv(.Inline) void { } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:2:5: error: functions marked inline must be stored in const or comptime var | |
| 12 | // tmp.zig:5:1: note: declared here |
test/cases/compile_errors/stage1/obj/assign_null_to_non-optional_pointer.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const a: *u8 = null; | |
| 2 | ||
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:1:16: error: expected type '*u8', found '@Type(.Null)' |
test/cases/compile_errors/stage1/obj/assign_through_constant_pointer.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | var cstr = "Hat"; | |
| 3 | cstr[0] = 'W'; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:13: error: cannot assign to constant |
test/cases/compile_errors/stage1/obj/assign_through_constant_slice.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | var cstr: []const u8 = "Hat"; | |
| 3 | cstr[0] = 'W'; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:13: error: cannot assign to constant |
test/cases/compile_errors/stage1/obj/assign_to_constant_field.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | field: i32, | |
| 3 | }; | |
| 4 | export fn derp() void { | |
| 5 | const f = Foo {.field = 1234,}; | |
| 6 | f.field = 0; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:6:15: error: cannot assign to constant |
test/cases/compile_errors/stage1/obj/assign_to_constant_variable.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | const a = 3; | |
| 3 | a = 4; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: cannot assign to constant |
test/cases/compile_errors/stage1/obj/assign_too_big_number_to_u16.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var vga_mem: u16 = 0xB8000; | |
| 3 | _ = vga_mem; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:24: error: integer value 753664 cannot be coerced to type 'u16' |
test/cases/compile_errors/stage1/obj/assign_unreachable.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | const a = return; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: unreachable code | |
| 10 | // tmp.zig:2:15: note: control flow is diverted here |
test/cases/compile_errors/stage1/obj/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: u32 = 0; | |
| 3 | @atomicStore(u32, &x, 1, .Acquire); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:30: error: @atomicStore atomic ordering must not be Acquire or AcqRel |
test/cases/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; | |
| 2 | export fn f() void { | |
| 3 | var x: i32 = 1234; | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Monotonic, AtomicOrder.SeqCst)) {} | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:4:81: error: failure atomic ordering must be no stricter than success |
test/cases/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; | |
| 2 | export fn f() void { | |
| 3 | var x: i32 = 1234; | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Unordered, AtomicOrder.Unordered)) {} | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:4:58: error: success atomic ordering must be Monotonic or stricter |
test/cases/compile_errors/stage1/obj/atomic_orderings_of_fence_Acquire_or_stricter.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | @fence(.Monotonic); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:12: error: atomic ordering must be Acquire or stricter |
test/cases/compile_errors/stage1/obj/atomicrmw_with_bool_op_not_.Xchg.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var x = false; | |
| 3 | _ = @atomicRmw(bool, &x, .Add, true, .SeqCst); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:30: error: @atomicRmw with bool only allowed with .Xchg |
test/cases/compile_errors/stage1/obj/atomicrmw_with_enum_op_not_.Xchg.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const E = enum(u8) { | |
| 3 | a, | |
| 4 | b, | |
| 5 | c, | |
| 6 | d, | |
| 7 | }; | |
| 8 | var x: E = .a; | |
| 9 | _ = @atomicRmw(E, &x, .Add, .b, .SeqCst); | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:9:27: error: @atomicRmw with enum only allowed with .Xchg |
test/cases/compile_errors/stage1/obj/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: f32 = 0; | |
| 3 | _ = @atomicRmw(f32, &x, .And, 2, .SeqCst); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:29: error: @atomicRmw with float only allowed with .Xchg, .Add and .Sub |
test/cases/compile_errors/stage1/obj/attempt_to_cast_enum_literal_to_error.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | switch (error.Hi) { | |
| 3 | .Hi => {}, | |
| 4 | } | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:9: error: expected type 'error{Hi}', found '@Type(.EnumLiteral)' |
test/cases/compile_errors/stage1/obj/attempt_to_close_over_comptime_variable_from_outer_scope.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | fn SimpleList(comptime L: usize) type { | |
| 2 | var T = u8; | |
| 3 | return struct { | |
| 4 | array: [L]T, | |
| 5 | }; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:19: error: mutable 'T' not accessible from here | |
| 13 | // tmp.zig:2:9: note: declared mutable here | |
| 14 | // tmp.zig:3:12: note: crosses namespace boundary here |
test/cases/compile_errors/stage1/obj/attempt_to_create_17_bit_float_type.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const builtin = @import("std").builtin; | |
| 2 | comptime { | |
| 3 | _ = @Type(.{ .Float = .{ .bits = 17 } }); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:16: error: 17-bit float unsupported |
test/cases/compile_errors/stage1/obj/attempt_to_negate_a_non-integer_non-float_or_non-vector_type.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | fn foo() anyerror!u32 { | |
| 2 | return 1; | |
| 3 | } | |
| 4 | ||
| 5 | export fn entry() void { | |
| 6 | const x = -foo(); | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:6:15: error: negation of type 'anyerror!u32' |
test/cases/compile_errors/stage1/obj/attempted_double_ampersand.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry(a: bool, b: bool) i32 { | |
| 2 | if (a && b) { | |
| 3 | return 1234; | |
| 4 | } | |
| 5 | return 5678; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:2:11: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND |
test/cases/compile_errors/stage1/obj/attempted_double_pipe_on_boolean_values.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn entry(a: bool, b: bool) i32 { | |
| 2 | if (a || b) { | |
| 3 | return 1234; | |
| 4 | } | |
| 5 | return 5678; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:2:9: error: expected error set type, found 'bool' | |
| 13 | // tmp.zig:2:11: note: `||` merges error sets; `or` performs boolean OR |
test/cases/compile_errors/stage1/obj/attempted_implicit_cast_from_T_to_slice_const_T.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x: [*]const bool = true; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:30: error: expected type '[*]const bool', found 'bool' |
test/cases/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_sliceT.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const u: u32 = 42; | |
| 3 | const x: []u32 = &u; | |
| 4 | _ = x; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:23: error: expected type '[]u32', found '*const u32' |
test/cases/compile_errors/stage1/obj/bad_identifier_in_function_with_struct_defined_inside_function_which_references_local_const.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const BlockKind = u32; | |
| 3 | ||
| 4 | const Block = struct { | |
| 5 | kind: BlockKind, | |
| 6 | }; | |
| 7 | ||
| 8 | bogus; | |
| 9 | ||
| 10 | _ = Block; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:8:5: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/stage1/obj/bad_import.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | const bogus = @import("bogus-does-not-exist.zig",); | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:23: error: unable to load '${DIR}bogus-does-not-exist.zig': FileNotFound |
test/cases/compile_errors/stage1/obj/bad_usage_of_call.zig deleted-30| ... | ... | @@ -1,30 +0,0 @@ |
| 1 | export fn entry1() void { | |
| 2 | @call(.{}, foo, {}); | |
| 3 | } | |
| 4 | export fn entry2() void { | |
| 5 | comptime @call(.{ .modifier = .never_inline }, foo, .{}); | |
| 6 | } | |
| 7 | export fn entry3() void { | |
| 8 | comptime @call(.{ .modifier = .never_tail }, foo, .{}); | |
| 9 | } | |
| 10 | export fn entry4() void { | |
| 11 | @call(.{ .modifier = .never_inline }, bar, .{}); | |
| 12 | } | |
| 13 | export fn entry5(c: bool) void { | |
| 14 | var baz = if (c) baz1 else baz2; | |
| 15 | @call(.{ .modifier = .compile_time }, baz, .{}); | |
| 16 | } | |
| 17 | fn foo() void {} | |
| 18 | fn bar() callconv(.Inline) void {} | |
| 19 | fn baz1() void {} | |
| 20 | fn baz2() void {} | |
| 21 | ||
| 22 | // error | |
| 23 | // backend=stage1 | |
| 24 | // target=native | |
| 25 | // | |
| 26 | // tmp.zig:2:21: error: expected tuple or struct, found 'void' | |
| 27 | // tmp.zig:5:14: error: unable to perform 'never_inline' call at compile-time | |
| 28 | // tmp.zig:8:14: error: unable to perform 'never_tail' call at compile-time | |
| 29 | // tmp.zig:11:5: error: no-inline call of inline function | |
| 30 | // tmp.zig:15:5: error: the specified modifier requires a comptime-known function |
test/cases/compile_errors/stage1/obj/bin_and_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a &= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/bin_and_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a & a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/bin_not_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = ~a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/bin_or_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a |= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/bin_or_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a | a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/bin_xor_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a ^= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/bin_xor_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a ^ a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/binary_not_on_number_literal.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const TINY_QUANTUM_SHIFT = 4; | |
| 2 | const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT; | |
| 3 | var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1); | |
| 4 | ||
| 5 | export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:60: error: unable to perform binary not operation on type 'comptime_int' |
test/cases/compile_errors/stage1/obj/bitCast_same_size_but_bit_count_mismatch.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry(byte: u8) void { | |
| 2 | var oops = @bitCast(u7, byte); | |
| 3 | _ = oops; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:25: error: destination type 'u7' has 7 bits but source type 'u8' has 8 bits |
test/cases/compile_errors/stage1/obj/bitCast_with_different_sizes_inside_an_expression.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var foo = (@bitCast(u8, @as(f32, 1.0)) == 0xf); | |
| 3 | _ = foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:25: error: destination type 'u8' has size 1 but source type 'f32' has size 4 |
test/cases/compile_errors/stage1/obj/bit_shifting_only_works_on_integer_types.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = &@as(u8, 1) << 10; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8' |
test/cases/compile_errors/stage1/obj/bogus_method_call_on_slice.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | var self = "aoeu"; | |
| 2 | fn f(m: []const u8) void { | |
| 3 | m.copy(u8, self[0..], m); | |
| 4 | } | |
| 5 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:6: error: no member named 'copy' in '[]const u8' |
test/cases/compile_errors/stage1/obj/bool_not_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: bool = undefined; | |
| 3 | _ = !a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/branch_on_undefined_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const x = if (undefined) true else false; | |
| 2 | ||
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(x)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:1:15: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/call_assigned_to_constant.zig deleted-24| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | x: i32, | |
| 3 | }; | |
| 4 | fn foo() Foo { | |
| 5 | return .{ .x = 42 }; | |
| 6 | } | |
| 7 | fn bar(val: anytype) Foo { | |
| 8 | return .{ .x = val }; | |
| 9 | } | |
| 10 | export fn entry() void { | |
| 11 | const baz: Foo = undefined; | |
| 12 | baz = foo(); | |
| 13 | } | |
| 14 | export fn entry1() void { | |
| 15 | const baz: Foo = undefined; | |
| 16 | baz = bar(42); | |
| 17 | } | |
| 18 | ||
| 19 | // error | |
| 20 | // backend=stage1 | |
| 21 | // target=native | |
| 22 | // | |
| 23 | // tmp.zig:12:14: error: cannot assign to constant | |
| 24 | // tmp.zig:16:14: error: cannot assign to constant |
test/cases/compile_errors/stage1/obj/calling_var_args_extern_function_passing_array_instead_of_pointer.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | foo("hello".*,); | |
| 3 | } | |
| 4 | pub extern fn foo(format: *const u8, ...) void; | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:16: error: expected type '*const u8', found '[5:0]u8' |
test/cases/compile_errors/stage1/obj/cast_enum_literal_to_enum_but_it_doesnt_match.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Foo = enum { | |
| 2 | a, | |
| 3 | b, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const x: Foo = .c; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:6:20: error: enum 'Foo' has no field named 'c' | |
| 15 | // tmp.zig:1:13: note: 'Foo' declared here |
test/cases/compile_errors/stage1/obj/cast_negative_integer_literal_to_usize.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @as(usize, -10); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:26: error: cannot cast negative value -10 to unsigned integer type 'usize' |
test/cases/compile_errors/stage1/obj/cast_negative_value_to_unsigned_integer.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | comptime { | |
| 2 | const value: i32 = -1; | |
| 3 | const unsigned = @intCast(u32, value); | |
| 4 | _ = unsigned; | |
| 5 | } | |
| 6 | export fn entry1() void { | |
| 7 | const value: i32 = -1; | |
| 8 | const unsigned: u32 = value; | |
| 9 | _ = unsigned; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:3:22: error: attempt to cast negative value to unsigned integer | |
| 17 | // tmp.zig:8:27: error: cannot cast negative value -1 to unsigned integer type 'u32' |
test/cases/compile_errors/stage1/obj/cast_unreachable.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn f() i32 { | |
| 2 | return @as(i32, return 1); | |
| 3 | } | |
| 4 | export fn entry() void { _ = f(); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:12: error: unreachable code | |
| 11 | // tmp.zig:2:21: note: control flow is diverted here |
test/cases/compile_errors/stage1/obj/casting_bit_offset_pointer_to_regular_pointer.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | const BitField = packed struct { | |
| 2 | a: u3, | |
| 3 | b: u3, | |
| 4 | c: u2, | |
| 5 | }; | |
| 6 | ||
| 7 | fn foo(bit_field: *const BitField) u3 { | |
| 8 | return bar(&bit_field.b); | |
| 9 | } | |
| 10 | ||
| 11 | fn bar(x: *const u3) u3 { | |
| 12 | return x.*; | |
| 13 | } | |
| 14 | ||
| 15 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 16 | ||
| 17 | // error | |
| 18 | // backend=stage1 | |
| 19 | // target=native | |
| 20 | // | |
| 21 | // tmp.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3' |
test/cases/compile_errors/stage1/obj/catch_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: anyerror!bool = undefined; | |
| 3 | _ = a catch false; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/chained_comparison_operators.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn a(value: u32) bool { | |
| 2 | return 1 < value < 1000; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:22: error: comparison operators cannot be chained |
test/cases/compile_errors/stage1/obj/cmpxchg_with_float.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: f32 = 0; | |
| 3 | _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32' |
test/cases/compile_errors/stage1/obj/colliding_invalid_top_level_functions.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn func() bogus {} | |
| 2 | fn func() bogus {} | |
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(func)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:1: error: redeclaration of 'func' | |
| 10 | // tmp.zig:1:1: note: other declaration here |
test/cases/compile_errors/stage1/obj/comparing_a_non-optional_pointer_against_null.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: i32 = 1; | |
| 3 | _ = &x == null; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:12: error: comparison of '*i32' with null |
test/cases/compile_errors/stage1/obj/comparing_against_undefined_produces_undefined_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if (2 == undefined) {} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/comparison_operators_with_undefined_value.zig deleted-47| ... | ... | @@ -1,47 +0,0 @@ |
| 1 | // operator == | |
| 2 | comptime { | |
| 3 | var a: i64 = undefined; | |
| 4 | var x: i32 = 0; | |
| 5 | if (a == a) x += 1; | |
| 6 | } | |
| 7 | // operator != | |
| 8 | comptime { | |
| 9 | var a: i64 = undefined; | |
| 10 | var x: i32 = 0; | |
| 11 | if (a != a) x += 1; | |
| 12 | } | |
| 13 | // operator > | |
| 14 | comptime { | |
| 15 | var a: i64 = undefined; | |
| 16 | var x: i32 = 0; | |
| 17 | if (a > a) x += 1; | |
| 18 | } | |
| 19 | // operator < | |
| 20 | comptime { | |
| 21 | var a: i64 = undefined; | |
| 22 | var x: i32 = 0; | |
| 23 | if (a < a) x += 1; | |
| 24 | } | |
| 25 | // operator >= | |
| 26 | comptime { | |
| 27 | var a: i64 = undefined; | |
| 28 | var x: i32 = 0; | |
| 29 | if (a >= a) x += 1; | |
| 30 | } | |
| 31 | // operator <= | |
| 32 | comptime { | |
| 33 | var a: i64 = undefined; | |
| 34 | var x: i32 = 0; | |
| 35 | if (a <= a) x += 1; | |
| 36 | } | |
| 37 | ||
| 38 | // error | |
| 39 | // backend=stage1 | |
| 40 | // target=native | |
| 41 | // | |
| 42 | // tmp.zig:5:11: error: use of undefined value here causes undefined behavior | |
| 43 | // tmp.zig:11:11: error: use of undefined value here causes undefined behavior | |
| 44 | // tmp.zig:17:11: error: use of undefined value here causes undefined behavior | |
| 45 | // tmp.zig:23:11: error: use of undefined value here causes undefined behavior | |
| 46 | // tmp.zig:29:11: error: use of undefined value here causes undefined behavior | |
| 47 | // tmp.zig:35:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/comparison_with_error_union_and_error_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var number_or_error: anyerror!i32 = error.SomethingAwful; | |
| 3 | _ = number_or_error == error.SomethingAwful; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:25: error: operator not allowed for type 'anyerror!i32' |
test/cases/compile_errors/stage1/obj/compileError_shows_traceback_of_references_that_caused_it.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const foo = @compileError("aoeu",); | |
| 2 | ||
| 3 | const bar = baz + foo; | |
| 4 | const baz = 1; | |
| 5 | ||
| 6 | export fn entry() i32 { | |
| 7 | return bar; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:1:13: error: aoeu |
test/cases/compile_errors/stage1/obj/compile_error_in_struct_init_expression.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | a: i32 = crap, | |
| 3 | b: i32, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | var x = Foo{ | |
| 7 | .b = 5, | |
| 8 | }; | |
| 9 | _ = x; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:2:14: error: use of undeclared identifier 'crap' |
test/cases/compile_errors/stage1/obj/compile_error_when_evaluating_return_type_of_inferred_error_set.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const Car = struct { | |
| 2 | foo: *SymbolThatDoesNotExist, | |
| 3 | pub fn init() !Car {} | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const car = Car.init(); | |
| 7 | _ = car; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist' |
test/cases/compile_errors/stage1/obj/compile_log_a_pointer_to_an_opaque_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | @compileLog(@ptrCast(*const anyopaque, &entry)); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: found compile log statement |
test/cases/compile_errors/stage1/obj/compile_log_statement_warning_deduplication_in_generic_fn.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | inner(1); | |
| 3 | inner(2); | |
| 4 | } | |
| 5 | fn inner(comptime n: usize) void { | |
| 6 | comptime var i = 0; | |
| 7 | inline while (i < n) : (i += 1) { @compileLog("!@#$"); } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:7:39: error: found compile log statement |
test/cases/compile_errors/stage1/obj/comptime_cast_enum_to_union_but_field_has_payload.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | const Letter = enum { A, B, C }; | |
| 2 | const Value = union(Letter) { | |
| 3 | A: i32, | |
| 4 | B, | |
| 5 | C, | |
| 6 | }; | |
| 7 | export fn entry() void { | |
| 8 | var x: Value = Letter.A; | |
| 9 | _ = x; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:8:26: error: cast to union 'Value' must initialize 'i32' field 'A' | |
| 17 | // tmp.zig:3:5: note: field 'A' declared here |
test/cases/compile_errors/stage1/obj/comptime_slice_of_undefined_pointer_non-zero_len.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const slice = @as([*]i32, undefined)[0..1]; | |
| 3 | _ = slice; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:41: error: non-zero length slice of undefined pointer |
test/cases/compile_errors/stage1/obj/comptime_struct_field_no_init_value.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | comptime b: i32, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var f: Foo = undefined; | |
| 6 | _ = f; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:2:5: error: comptime field without default initialization value |
test/cases/compile_errors/stage1/obj/const_is_a_statement_not_an_expression.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | (const a = 0); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:6: error: expected expression, found 'const' |
test/cases/compile_errors/stage1/obj/container_init_with_non-type.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const zero: i32 = 0; | |
| 2 | const a = zero{1}; | |
| 3 | ||
| 4 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:11: error: expected type 'type', found 'i32' |
test/cases/compile_errors/stage1/obj/control_flow_uses_comptime_var_at_runtime.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | comptime var i = 0; | |
| 3 | while (i < 5) : (i += 1) { | |
| 4 | bar(); | |
| 5 | } | |
| 6 | } | |
| 7 | ||
| 8 | fn bar() void { } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:3:5: error: control flow attempts to use compile-time variable at runtime | |
| 15 | // tmp.zig:3:24: note: compile-time variable assigned here |
test/cases/compile_errors/stage1/obj/declaration_between_fields.zig deleted-24| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | const S = struct { | |
| 2 | const foo = 2; | |
| 3 | const bar = 2; | |
| 4 | const baz = 2; | |
| 5 | a: struct { | |
| 6 | a: u32, | |
| 7 | b: u32, | |
| 8 | }, | |
| 9 | const foo1 = 2; | |
| 10 | const bar1 = 2; | |
| 11 | const baz1 = 2; | |
| 12 | b: usize, | |
| 13 | }; | |
| 14 | comptime { | |
| 15 | _ = S; | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage1 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // tmp.zig:9:5: error: declarations are not allowed between container fields | |
| 23 | // tmp.zig:5:5: note: field before declarations here | |
| 24 | // tmp.zig:12:5: note: field after declarations here |
test/cases/compile_errors/stage1/obj/declaration_with_same_name_as_primitive_must_use_special_syntax.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const u8 = u16; | |
| 2 | export fn entry() void { | |
| 3 | const a: u8 = 300; | |
| 4 | _ = a; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:1:7: error: name shadows primitive 'u8' | |
| 12 | // tmp.zig:1:7: note: consider using @"u8" to disambiguate |
test/cases/compile_errors/stage1/obj/deduplicate_undeclared_identifier.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | x += 1; | |
| 3 | } | |
| 4 | export fn b() void { | |
| 5 | x += 1; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:2:5: error: use of undeclared identifier 'x' |
test/cases/compile_errors/stage1/obj/deref_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: *u8 = undefined; | |
| 3 | _ = a.*; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: attempt to dereference undefined value |
test/cases/compile_errors/stage1/obj/div_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a /= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/div_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a / a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/dont_implicit_cast_double_pointer_to_anyopaque.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var a: u32 = 1; | |
| 3 | var ptr: *align(@alignOf(u32)) anyopaque = &a; | |
| 4 | var b: *u32 = @ptrCast(*u32, ptr); | |
| 5 | var ptr2: *anyopaque = &b; | |
| 6 | _ = ptr2; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:5:29: error: expected type '*anyopaque', found '**u32' |
test/cases/compile_errors/stage1/obj/duplicate_boolean_switch_value.zig deleted-23| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | comptime { | |
| 2 | const x = switch (true) { | |
| 3 | true => false, | |
| 4 | false => true, | |
| 5 | true => false, | |
| 6 | }; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | comptime { | |
| 10 | const x = switch (true) { | |
| 11 | false => true, | |
| 12 | true => false, | |
| 13 | false => true, | |
| 14 | }; | |
| 15 | _ = x; | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage1 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // tmp.zig:5:9: error: duplicate switch value | |
| 23 | // tmp.zig:13:9: error: duplicate switch value |
test/cases/compile_errors/stage1/obj/duplicate_error_value_in_error_set.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Foo = error { | |
| 2 | Bar, | |
| 3 | Bar, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const a: Foo = undefined; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:3:5: error: duplicate error set field 'Bar' | |
| 15 | // tmp.zig:2:5: note: previous declaration here |
test/cases/compile_errors/stage1/obj/duplicate_field_in_struct_value_expression.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | const A = struct { | |
| 2 | x : i32, | |
| 3 | y : i32, | |
| 4 | z : i32, | |
| 5 | }; | |
| 6 | export fn f() void { | |
| 7 | const a = A { | |
| 8 | .z = 1, | |
| 9 | .y = 2, | |
| 10 | .x = 3, | |
| 11 | .z = 4, | |
| 12 | }; | |
| 13 | _ = a; | |
| 14 | } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage1 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // tmp.zig:11:9: error: duplicate field |
test/cases/compile_errors/stage1/obj/duplicate_struct_field.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | Bar: i32, | |
| 3 | Bar: usize, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const a: Foo = undefined; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:3:5: error: duplicate struct field: 'Bar' | |
| 15 | // tmp.zig:2:5: note: other field here |
test/cases/compile_errors/stage1/obj/duplicate_union_field.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Foo = union { | |
| 2 | Bar: i32, | |
| 3 | Bar: usize, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | const a: Foo = undefined; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:3:5: error: duplicate union field: 'Bar' | |
| 15 | // tmp.zig:2:5: note: other field here |
test/cases/compile_errors/stage1/obj/embedFile_with_bogus_file.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const resource = @embedFile("bogus.txt",); | |
| 2 | ||
| 3 | export fn entry() usize { return @sizeOf(@TypeOf(resource)); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:1:29: error: unable to find ' |
test/cases/compile_errors/stage1/obj/empty_for_loop_body.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | for(undefined) |x|; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:23: error: expected block or assignment, found ';' |
test/cases/compile_errors/stage1/obj/empty_if_body.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | if(true); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:13: error: expected block or assignment, found ';' |
test/cases/compile_errors/stage1/obj/empty_switch_on_an_integer.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var x: u32 = 0; | |
| 3 | switch(x) {} | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: switch must handle all possibilities |
test/cases/compile_errors/stage1/obj/empty_while_loop_body.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | while(true); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:16: error: expected block or assignment, found ';' |
test/cases/compile_errors/stage1/obj/enum_in_field_count_range_but_not_matching_tag.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Foo = enum(u32) { | |
| 2 | A = 10, | |
| 3 | B = 11, | |
| 4 | }; | |
| 5 | export fn entry() void { | |
| 6 | var x = @intToEnum(Foo, 0); | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:6:13: error: enum 'Foo' has no tag matching integer value 0 | |
| 15 | // tmp.zig:1:13: note: 'Foo' declared here |
test/cases/compile_errors/stage1/obj/enum_with_0_fields.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | const Foo = enum {}; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:13: error: enum declarations must have at least one tag |
test/cases/compile_errors/stage1/obj/enum_with_declarations_unavailable_for_reify_type.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(@typeInfo(enum { foo, const bar = 1; })); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:15: error: Type.Enum.decls must be empty for @Type |
test/cases/compile_errors/stage1/obj/error_union_operator_with_non_error_set_LHS.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | comptime { | |
| 2 | const z = i32!i32; | |
| 3 | var x: z = undefined; | |
| 4 | _ = x; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:2:15: error: expected error set type, found type 'i32' |
test/cases/compile_errors/stage1/obj/exceeded_maximum_bit_width_of_integer.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | export fn entry1() void { | |
| 2 | const T = u65536; | |
| 3 | _ = T; | |
| 4 | } | |
| 5 | export fn entry2() void { | |
| 6 | var x: i65536 = 1; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:2:15: error: primitive integer type 'u65536' exceeds maximum bit width of 65535 | |
| 15 | // tmp.zig:6:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535 |
test/cases/compile_errors/stage1/obj/explicit_cast_float_literal_to_integer_when_there_is_a_fraction_component.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() i32 { | |
| 2 | return @as(i32, 12.34); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:21: error: fractional component prevents float value 12.340000 from being casted to type 'i32' |
test/cases/compile_errors/stage1/obj/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Set1 = error {A, B}; | |
| 2 | const Set2 = error {A, C}; | |
| 3 | comptime { | |
| 4 | var x = Set1.B; | |
| 5 | var y = @errSetCast(Set2, x); | |
| 6 | _ = y; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:5:13: error: error.B not a member of error set 'Set2' |
test/cases/compile_errors/stage1/obj/extern_union_field_missing_type.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Letter = extern union { | |
| 2 | A, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var a = Letter { .A = {} }; | |
| 6 | _ = a; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:2:5: error: union field missing type |
test/cases/compile_errors/stage1/obj/extern_variable_has_no_type.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | extern var foo; | |
| 2 | pub export fn entry() void { | |
| 3 | foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:1:8: error: unable to infer variable type |
test/cases/compile_errors/stage1/obj/fieldParentPtr-bad_field_name.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Foo = extern struct { | |
| 2 | derp: i32, | |
| 3 | }; | |
| 4 | export fn foo(a: *i32) *Foo { | |
| 5 | return @fieldParentPtr(Foo, "a", a); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:5:33: error: struct 'Foo' has no field 'a' |
test/cases/compile_errors/stage1/obj/fieldParentPtr-non_struct.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const Foo = i32; | |
| 2 | export fn foo(a: *i32) *Foo { | |
| 3 | return @fieldParentPtr(Foo, "a", a); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:28: error: expected struct type, found 'i32' |
test/cases/compile_errors/stage1/obj/field_type_supplied_in_an_enum.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Letter = enum { | |
| 2 | A: void, | |
| 3 | B, | |
| 4 | C, | |
| 5 | }; | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:2:8: error: enum fields do not have types | |
| 12 | // tmp.zig:1:16: note: consider 'union(enum)' here to make it a tagged union |
test/cases/compile_errors/stage1/obj/function_call_assigned_to_incorrect_type.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var arr: [4]f32 = undefined; | |
| 3 | arr = concat(); | |
| 4 | } | |
| 5 | fn concat() [16]f32 { | |
| 6 | return [1]f32{0}**16; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:3:17: error: expected type '[4]f32', found '[16]f32' |
test/cases/compile_errors/stage1/obj/function_prototype_with_no_body.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn foo() void; | |
| 2 | export fn entry() void { | |
| 3 | foo(); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:1:1: error: non-extern function has no body |
test/cases/compile_errors/stage1/obj/function_with_invalid_return_type.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | export fn foo() boid {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:17: error: use of undeclared identifier 'boid' |
test/cases/compile_errors/stage1/obj/generic_function_call_assigned_to_incorrect_type.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var res: []i32 = undefined; | |
| 3 | res = myAlloc(i32); | |
| 4 | } | |
| 5 | fn myAlloc(comptime arg: type) anyerror!arg{ | |
| 6 | unreachable; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:3:18: error: expected type '[]i32', found 'anyerror!i32 |
test/cases/compile_errors/stage1/obj/global_variable_initializer_must_be_constant_expression.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | extern fn foo() i32; | |
| 2 | const x = foo(); | |
| 3 | export fn entry() i32 { return x; } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:11: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/obj/hasDecl_with_non-container.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @hasDecl(i32, "hi"); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:18: error: expected struct, enum, or union; found 'i32' |
test/cases/compile_errors/stage1/obj/if_condition_is_bool_not_int.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | if (0) {} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:9: error: expected type 'bool', found 'comptime_int' |
test/cases/compile_errors/stage1/obj/ignored_assert-err-ok_return_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | bar() catch unreachable; | |
| 3 | } | |
| 4 | fn bar() anyerror!i32 { return 0; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:11: error: expression value is ignored |
test/cases/compile_errors/stage1/obj/ignored_comptime_statement_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | comptime {1;} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:15: error: expression value is ignored |
test/cases/compile_errors/stage1/obj/ignored_comptime_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | comptime 1; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: expression value is ignored |
test/cases/compile_errors/stage1/obj/ignored_deferred_statement_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | defer {1;} | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:12: error: expression value is ignored |
test/cases/compile_errors/stage1/obj/ignored_return_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | bar(); | |
| 3 | } | |
| 4 | fn bar() i32 { return 0; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:8: error: expression value is ignored |
test/cases/compile_errors/stage1/obj/ignored_statement_value.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | 1; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: expression value is ignored |
test/cases/compile_errors/stage1/obj/implicit_semicolon-block_expr.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = {}; | |
| 3 | var good = {}; | |
| 4 | _ = {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:11: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-block_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | {} | |
| 3 | var good = {}; | |
| 4 | ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:9: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-comptime_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = comptime {}; | |
| 3 | var good = {}; | |
| 4 | _ = comptime {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:20: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-comptime_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | comptime {} | |
| 3 | var good = {}; | |
| 4 | comptime ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:18: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-defer.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | defer {} | |
| 3 | var good = {}; | |
| 4 | defer ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:15: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-for_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = for(foo()) |_| {}; | |
| 3 | var good = {}; | |
| 4 | _ = for(foo()) |_| {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:26: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-for_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | for(foo()) |_| {} | |
| 3 | var good = {}; | |
| 4 | for(foo()) |_| ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:24: error: expected ';' or 'else' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {} else if(true) {} else {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} else if(true) {} else {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:45: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} else if(true) {} else {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) else if(true) ({}) else ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:47: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if-else-if_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {} else if(true) {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} else if(true) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:37: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if-else-if_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} else if(true) {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) else if(true) ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:37: error: expected ';' or 'else' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if-else_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {} else {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} else {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:28: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if-else_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} else {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) else ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:28: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if(true) {}; | |
| 3 | var good = {}; | |
| 4 | _ = if(true) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:20: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-if_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if(true) {} | |
| 3 | var good = {}; | |
| 4 | if(true) ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:18: error: expected ';' or 'else' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-test_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = if (foo()) |_| {}; | |
| 3 | var good = {}; | |
| 4 | _ = if (foo()) |_| {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:26: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-test_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if (foo()) |_| {} | |
| 3 | var good = {}; | |
| 4 | if (foo()) |_| ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:24: error: expected ';' or 'else' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-while-continue_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = while(true):({}) {}; | |
| 3 | var good = {}; | |
| 4 | _ = while(true):({}) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:28: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-while-continue_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | while(true):({}) {} | |
| 3 | var good = {}; | |
| 4 | while(true):({}) ({}) | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:26: error: expected ';' or 'else' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-while_expression.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = while(true) {}; | |
| 3 | var good = {}; | |
| 4 | _ = while(true) {} | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:23: error: expected ';' after statement |
test/cases/compile_errors/stage1/obj/implicit_semicolon-while_statement.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | while(true) {} | |
| 3 | var good = {}; | |
| 4 | while(true) 1 | |
| 5 | var bad = {}; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:18: error: expected ';' or 'else' after statement |
test/cases/compile_errors/stage1/obj/import_outside_package_path.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | comptime{ | |
| 2 | _ = @import("../a.zig"); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:9: error: import of file outside package path: '../a.zig' |
test/cases/compile_errors/stage1/obj/inferred_array_size_invalid_here.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = [_]u8; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | export fn entry2() void { | |
| 6 | const S = struct { a: *const [_]u8 }; | |
| 7 | var a = .{ S{} }; | |
| 8 | _ = a; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // tmp.zig:2:16: error: unable to infer array size | |
| 16 | // tmp.zig:6:35: error: unable to infer array size |
test/cases/compile_errors/stage1/obj/inferring_error_set_of_function_pointer.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | comptime { | |
| 2 | const z: ?fn()!void = null; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:19: error: function prototype may not have inferred error set |
test/cases/compile_errors/stage1/obj/initializing_array_with_struct_syntax.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = [_]u8{ .y = 2 }; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:15: error: initializing array with struct syntax |
test/cases/compile_errors/stage1/obj/int_to_err_global_invalid_number.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Set1 = error{ | |
| 2 | A, | |
| 3 | B, | |
| 4 | }; | |
| 5 | comptime { | |
| 6 | var x: u16 = 3; | |
| 7 | var y = @intToError(x); | |
| 8 | _ = y; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // tmp.zig:7:13: error: integer value 3 represents no error |
test/cases/compile_errors/stage1/obj/int_to_err_non_global_invalid_number.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | const Set1 = error{ | |
| 2 | A, | |
| 3 | B, | |
| 4 | }; | |
| 5 | const Set2 = error{ | |
| 6 | A, | |
| 7 | C, | |
| 8 | }; | |
| 9 | comptime { | |
| 10 | var x = @errorToInt(Set1.B); | |
| 11 | var y = @errSetCast(Set2, @intToError(x)); | |
| 12 | _ = y; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage1 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // tmp.zig:11:13: error: error.B not a member of error set 'Set2' |
test/cases/compile_errors/stage1/obj/integer_overflow_error.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | const x : u8 = 300; | |
| 2 | export fn entry() usize { return @sizeOf(@TypeOf(x)); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:1:16: error: integer value 300 cannot be coerced to type 'u8' |
test/cases/compile_errors/stage1/obj/integer_underflow_error.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @intToPtr(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:78: error: operation caused overflow |
test/cases/compile_errors/stage1/obj/invalid_break_expression.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | break; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: break expression outside loop |
test/cases/compile_errors/stage1/obj/invalid_builtin_fn.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | fn f() @bogus(foo) { | |
| 2 | } | |
| 3 | export fn entry() void { _ = f(); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:1:8: error: invalid builtin function: '@bogus' |
test/cases/compile_errors/stage1/obj/invalid_comparison_for_function_pointers.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn foo() void {} | |
| 2 | const invalid = foo > foo; | |
| 3 | ||
| 4 | export fn entry() usize { return @sizeOf(@TypeOf(invalid)); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: operator not allowed for type 'fn() void' |
test/cases/compile_errors/stage1/obj/invalid_continue_expression.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | continue; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: continue expression outside loop |
test/cases/compile_errors/stage1/obj/invalid_empty_unicode_escape.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const a = '\u{}'; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:19: error: empty unicode escape sequence |
test/cases/compile_errors/stage1/obj/invalid_exponent_in_float_literal-1.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x1.0p1ab1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:28: note: invalid byte: 'a' |
test/cases/compile_errors/stage1/obj/invalid_exponent_in_float_literal-2.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x1.0p50F; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:29: note: invalid byte: 'F' |
test/cases/compile_errors/stage1/obj/invalid_field_access_in_comptime.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | comptime { var x = doesnt_exist.whatever; _ = x; } | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:20: error: use of undeclared identifier 'doesnt_exist' |
test/cases/compile_errors/stage1/obj/invalid_field_in_struct_value_expression.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | const A = struct { | |
| 2 | x : i32, | |
| 3 | y : i32, | |
| 4 | z : i32, | |
| 5 | }; | |
| 6 | export fn f() void { | |
| 7 | const a = A { | |
| 8 | .z = 4, | |
| 9 | .y = 2, | |
| 10 | .foo = 42, | |
| 11 | }; | |
| 12 | _ = a; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage1 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // tmp.zig:10:9: error: no member named 'foo' in struct 'A' |
test/cases/compile_errors/stage1/obj/invalid_float_literal.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var bad_float :f32 = 0.0; | |
| 5 | bad_float = bad_float + .20; | |
| 6 | std.debug.assert(bad_float < 1.0); | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:5:29: error: expected expression, found '.' |
test/cases/compile_errors/stage1/obj/invalid_legacy_unicode_escape.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const a = '\U1234'; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:15: error: expected expression, found 'invalid bytes' | |
| 10 | // tmp.zig:2:18: note: invalid byte: '1' |
test/cases/compile_errors/stage1/obj/invalid_member_of_builtin_enum.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const builtin = @import("std").builtin; | |
| 2 | export fn entry() void { | |
| 3 | const foo = builtin.Mode.x86; | |
| 4 | _ = foo; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:29: error: container 'std.builtin.Mode' has no member called 'x86' |
test/cases/compile_errors/stage1/obj/invalid_pointer_for_var_type.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | extern fn ext() usize; | |
| 2 | var bytes: [ext()]u8 = undefined; | |
| 3 | export fn f() void { | |
| 4 | for (bytes) |*b, i| { | |
| 5 | b.* = @as(u8, i); | |
| 6 | } | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:2:13: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/obj/invalid_pointer_syntax.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var guid: *:0 const u8 = undefined; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:16: error: expected type expression, found ':' |
test/cases/compile_errors/stage1/obj/invalid_shift_amount_error.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const x : u8 = 2; | |
| 2 | fn f() u16 { | |
| 3 | return x << 8; | |
| 4 | } | |
| 5 | export fn entry() u16 { return f(); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:17: error: integer value 8 cannot be coerced to type 'u3' |
test/cases/compile_errors/stage1/obj/invalid_struct_field.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | const A = struct { x : i32, }; | |
| 2 | export fn f() void { | |
| 3 | var a : A = undefined; | |
| 4 | a.foo = 1; | |
| 5 | const y = a.bar; | |
| 6 | _ = y; | |
| 7 | } | |
| 8 | export fn g() void { | |
| 9 | var a : A = undefined; | |
| 10 | const y = a.bar; | |
| 11 | _ = y; | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage1 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // tmp.zig:4:6: error: no member named 'foo' in struct 'A' | |
| 19 | // tmp.zig:10:16: error: no member named 'bar' in struct 'A' |
test/cases/compile_errors/stage1/obj/invalid_type.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | fn a() bogus {} | |
| 2 | export fn entry() void { _ = a(); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:1:8: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/stage1/obj/invalid_type_used_in_array_type.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const Item = struct { | |
| 2 | field: SomeNonexistentType, | |
| 3 | }; | |
| 4 | var items: [100]Item = undefined; | |
| 5 | export fn entry() void { | |
| 6 | const a = items[0]; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:2:12: error: use of undeclared identifier 'SomeNonexistentType' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-1.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0._0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:23: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-10.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0__0e-1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:25: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-11.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e-1__0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:28: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-12.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0_x0.0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:23: note: invalid byte: 'x' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-13.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x_0.0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:23: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-14.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0x0.0_p1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:27: note: invalid byte: 'p' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-2.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0_.0; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:23: note: invalid byte: '.' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-3.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 0.0_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:25: note: invalid byte: ';' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-4.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e_1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:25: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-5.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e+_1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:26: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-6.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e-_1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:26: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-7.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1.0e-1_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:28: note: invalid byte: ';' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-9.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: f128 = 1__0.0e-1; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:23: note: invalid byte: '_' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-1.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:26: note: invalid byte: ';' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-2.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0b0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:28: note: invalid byte: ';' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-3.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0o0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:28: note: invalid byte: ';' |
test/cases/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-4.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn main() void { | |
| 2 | var bad: u128 = 0x0010_; | |
| 3 | _ = bad; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:21: error: expected expression, found 'invalid bytes' | |
| 11 | // tmp.zig:2:28: note: invalid byte: ';' |
test/cases/compile_errors/stage1/obj/invalid_union_field_access_in_comptime.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const Foo = union { | |
| 2 | Bar: u8, | |
| 3 | Baz: void, | |
| 4 | }; | |
| 5 | comptime { | |
| 6 | var foo = Foo {.Baz = {}}; | |
| 7 | const bar_val = foo.Bar; | |
| 8 | _ = bar_val; | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // tmp.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set |
test/cases/compile_errors/stage1/obj/issue_9346_return_outside_of_function_scope.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | pub const empty = return 1; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:19: error: 'return' outside function scope |
test/cases/compile_errors/stage1/obj/labeled_break_not_found.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | blah: while (true) { | |
| 3 | while (true) { | |
| 4 | break :outer; | |
| 5 | } | |
| 6 | } | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:4:20: error: label not found: 'outer' |
test/cases/compile_errors/stage1/obj/labeled_continue_not_found.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var i: usize = 0; | |
| 3 | blah: while (i < 10) : (i += 1) { | |
| 4 | while (true) { | |
| 5 | continue :outer; | |
| 6 | } | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:5:23: error: label not found: 'outer' |
test/cases/compile_errors/stage1/obj/local_shadows_global_that_occurs_later.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var foo = true; | |
| 3 | _ = foo; | |
| 4 | } | |
| 5 | fn foo() void {} | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:2:9: error: local shadows declaration of 'foo' | |
| 12 | // tmp.zig:5:1: note: declared here |
test/cases/compile_errors/stage1/obj/local_variable_redeclaration.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | const a : i32 = 0; | |
| 3 | var a = 0; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: redeclaration of local constant 'a' | |
| 11 | // tmp.zig:2:11: note: previous declaration here |
test/cases/compile_errors/stage1/obj/local_variable_redeclares_parameter.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn f(a : i32) void { | |
| 2 | const a = 0; | |
| 3 | } | |
| 4 | export fn entry() void { f(1); } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:11: error: redeclaration of function parameter 'a' | |
| 11 | // tmp.zig:1:6: note: previous declaration here |
test/cases/compile_errors/stage1/obj/local_variable_shadowing_global.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const Foo = struct {}; | |
| 2 | const Bar = struct {}; | |
| 3 | ||
| 4 | export fn entry() void { | |
| 5 | var Bar : i32 = undefined; | |
| 6 | _ = Bar; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:5:9: error: local shadows declaration of 'Bar' | |
| 14 | // tmp.zig:2:1: note: declared here |
test/cases/compile_errors/stage1/obj/locally_shadowing_a_primitive_type.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | const u8 = u16; | |
| 3 | const a: u8 = 300; | |
| 4 | _ = a; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:2:11: error: name shadows primitive 'u8' | |
| 12 | // tmp.zig:2:11: note: consider using @"u8" to disambiguate |
test/cases/compile_errors/stage1/obj/main_function_with_bogus_args_type.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | pub fn main(args: [][]bogus) !void {_ = args;} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:23: error: use of undeclared identifier 'bogus' |
test/cases/compile_errors/stage1/obj/missing_boolean_switch_value.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | comptime { | |
| 2 | const x = switch (true) { | |
| 3 | true => false, | |
| 4 | }; | |
| 5 | _ = x; | |
| 6 | } | |
| 7 | comptime { | |
| 8 | const x = switch (true) { | |
| 9 | false => true, | |
| 10 | }; | |
| 11 | _ = x; | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage1 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // tmp.zig:2:15: error: switch must handle all possibilities | |
| 19 | // tmp.zig:8:15: error: switch must handle all possibilities |
test/cases/compile_errors/stage1/obj/missing_else_clause.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | fn f(b: bool) void { | |
| 2 | const x : i32 = if (b) h: { break :h 1; }; | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | fn g(b: bool) void { | |
| 6 | const y = if (b) h: { break :h @as(i32, 1); }; | |
| 7 | _ = y; | |
| 8 | } | |
| 9 | export fn entry() void { f(true); g(true); } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // tmp.zig:2:21: error: expected type 'i32', found 'void' | |
| 16 | // tmp.zig:6:15: error: incompatible types: 'i32' and 'void' |
test/cases/compile_errors/stage1/obj/missing_field_in_struct_value_expression.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | const A = struct { | |
| 2 | x : i32, | |
| 3 | y : i32, | |
| 4 | z : i32, | |
| 5 | }; | |
| 6 | export fn f() void { | |
| 7 | // we want the error on the '{' not the 'A' because | |
| 8 | // the A could be a complicated expression | |
| 9 | const a = A { | |
| 10 | .z = 4, | |
| 11 | .y = 2, | |
| 12 | }; | |
| 13 | _ = a; | |
| 14 | } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage1 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // tmp.zig:9:17: error: missing field: 'x' |
test/cases/compile_errors/stage1/obj/missing_function_name.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | fn () void {} | |
| 2 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:1:1: error: missing function name |
test/cases/compile_errors/stage1/obj/missing_param_name.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | fn f(i32) void {} | |
| 2 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:1:6: error: missing parameter name |
test/cases/compile_errors/stage1/obj/missing_parameter_name_of_generic_function.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | fn dump(anytype) void {} | |
| 2 | export fn entry() void { | |
| 3 | var a: u8 = 9; | |
| 4 | dump(a); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:1:9: error: missing parameter name |
test/cases/compile_errors/stage1/obj/misspelled_type_with_pointer_only_reference.zig deleted-37| ... | ... | @@ -1,37 +0,0 @@ |
| 1 | const JasonHM = u8; | |
| 2 | const JasonList = *JsonNode; | |
| 3 | ||
| 4 | const JsonOA = union(enum) { | |
| 5 | JSONArray: JsonList, | |
| 6 | JSONObject: JasonHM, | |
| 7 | }; | |
| 8 | ||
| 9 | const JsonType = union(enum) { | |
| 10 | JSONNull: void, | |
| 11 | JSONInteger: isize, | |
| 12 | JSONDouble: f64, | |
| 13 | JSONBool: bool, | |
| 14 | JSONString: []u8, | |
| 15 | JSONArray: void, | |
| 16 | JSONObject: void, | |
| 17 | }; | |
| 18 | ||
| 19 | pub const JsonNode = struct { | |
| 20 | kind: JsonType, | |
| 21 | jobject: ?JsonOA, | |
| 22 | }; | |
| 23 | ||
| 24 | fn foo() void { | |
| 25 | var jll: JasonList = undefined; | |
| 26 | jll.init(1234); | |
| 27 | var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} }; | |
| 28 | _ = jd; | |
| 29 | } | |
| 30 | ||
| 31 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 32 | ||
| 33 | // error | |
| 34 | // backend=stage1 | |
| 35 | // target=native | |
| 36 | // | |
| 37 | // tmp.zig:5:16: error: use of undeclared identifier 'JsonList' |
test/cases/compile_errors/stage1/obj/mod_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a %= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/mod_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a % a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/mult_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a *= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/mult_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a * a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/mult_wrap_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a *%= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/mult_wrap_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a *% a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/multiple_function_definitions.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn a() void {} | |
| 2 | fn a() void {} | |
| 3 | export fn entry() void { a(); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:1: error: redeclaration of 'a' | |
| 10 | // tmp.zig:1:1: note: other declaration here |
test/cases/compile_errors/stage1/obj/negate_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = -a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:10: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/negate_wrap_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = -%a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/non-const_expression_function_call_with_struct_return_value_outside_function.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | x: i32, | |
| 3 | }; | |
| 4 | const a = get_it(); | |
| 5 | fn get_it() Foo { | |
| 6 | global_side_effect = true; | |
| 7 | return Foo {.x = 13}; | |
| 8 | } | |
| 9 | var global_side_effect = false; | |
| 10 | ||
| 11 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:6:26: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/obj/non-const_expression_in_struct_literal_outside_function.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | x: i32, | |
| 3 | }; | |
| 4 | const a = Foo {.x = get_it()}; | |
| 5 | extern fn get_it() i32; | |
| 6 | ||
| 7 | export fn entry() usize { return @sizeOf(@TypeOf(a)); } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:4:21: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/obj/non-const_switch_number_literal.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | const x = switch (bar()) { | |
| 3 | 1, 2 => 1, | |
| 4 | 3, 4 => 2, | |
| 5 | else => 3, | |
| 6 | }; | |
| 7 | _ = x; | |
| 8 | } | |
| 9 | fn bar() i32 { | |
| 10 | return 2; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:5:17: error: cannot store runtime value in type 'comptime_int' |
test/cases/compile_errors/stage1/obj/non-extern_function_with_var_args.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn foo(args: ...) void {} | |
| 2 | export fn entry() void { | |
| 3 | foo(); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:1:14: error: expected type expression, found '...' |
test/cases/compile_errors/stage1/obj/non-pure_function_returns_type.zig deleted-24| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | var a: u32 = 0; | |
| 2 | pub fn List(comptime T: type) type { | |
| 3 | a += 1; | |
| 4 | return SmallList(T, 8); | |
| 5 | } | |
| 6 | ||
| 7 | pub fn SmallList(comptime T: type, comptime STATIC_SIZE: usize) type { | |
| 8 | return struct { | |
| 9 | items: []T, | |
| 10 | length: usize, | |
| 11 | prealloc_items: [STATIC_SIZE]T, | |
| 12 | }; | |
| 13 | } | |
| 14 | ||
| 15 | export fn function_with_return_type_type() void { | |
| 16 | var list: List(i32) = undefined; | |
| 17 | list.length = 10; | |
| 18 | } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage1 | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // tmp.zig:3:7: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/obj/non_float_passed_to_floatToInt.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @floatToInt(i32, @as(i32, 54)); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:32: error: expected float type, found 'i32' |
test/cases/compile_errors/stage1/obj/non_int_passed_to_intToFloat.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @intToFloat(f32, 1.1); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:32: error: expected int type, found 'comptime_float' |
test/cases/compile_errors/stage1/obj/non_pointer_given_to_ptrToInt.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry(x: i32) usize { | |
| 2 | return @ptrToInt(x); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:22: error: expected pointer, found 'i32' |
test/cases/compile_errors/stage1/obj/normal_string_with_newline.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const foo = "a | |
| 2 | b"; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:1:13: error: expected expression, found 'invalid bytes' | |
| 9 | // tmp.zig:1:15: note: invalid byte: '\n' |
test/cases/compile_errors/stage1/obj/offsetOf-bad_field_name.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | derp: i32, | |
| 3 | }; | |
| 4 | export fn foo() usize { | |
| 5 | return @offsetOf(Foo, "a",); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:5:27: error: struct 'Foo' has no field 'a' |
test/cases/compile_errors/stage1/obj/offsetOf-non_struct.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const Foo = i32; | |
| 2 | export fn foo() usize { | |
| 3 | return @offsetOf(Foo, "a",); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:22: error: expected struct type, found 'i32' |
test/cases/compile_errors/stage1/obj/only_equality_binary_operator_allowed_for_error_sets.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | const z = error.A > error.B; | |
| 3 | _ = z; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:23: error: operator not allowed for errors |
test/cases/compile_errors/stage1/obj/or_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: bool = undefined; | |
| 3 | _ = a or a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/orelse_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: ?bool = undefined; | |
| 3 | _ = a orelse false; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/out_of_range_comptime_int_passed_to_floatToInt.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const x = @floatToInt(i8, 200); | |
| 3 | _ = x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:31: error: integer value 200 cannot be coerced to type 'i8' |
test/cases/compile_errors/stage1/obj/parameter_redeclaration.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | fn f(a : i32, a : i32) void { | |
| 2 | } | |
| 3 | export fn entry() void { f(1, 2); } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:1:15: error: redeclaration of function parameter 'a' | |
| 10 | // tmp.zig:1:6: note: previous declaration here |
test/cases/compile_errors/stage1/obj/parameter_shadowing_global.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Foo = struct {}; | |
| 2 | fn f(Foo: i32) void {} | |
| 3 | export fn entry() void { | |
| 4 | f(1234); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:2:6: error: local shadows declaration of 'Foo' | |
| 12 | // tmp.zig:1:1: note: declared here |
test/cases/compile_errors/stage1/obj/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; | |
| 2 | export fn entry() bool { | |
| 3 | var x: i32 align(1) = 1234; | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) {} | |
| 5 | return x == 5678; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:32: error: expected type '*i32', found '*align(1) i32' |
test/cases/compile_errors/stage1/obj/pointer_arithmetic_on_pointer-to-array.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var x: [10]u8 = undefined; | |
| 3 | var y = &x; | |
| 4 | var z = y + 1; | |
| 5 | _ = z; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:4:17: error: integer value 1 cannot be coerced to type '*[10]u8' |
test/cases/compile_errors/stage1/obj/popCount-non-integer.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry(x: f32) u32 { | |
| 2 | return @popCount(f32, x); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:22: error: expected integer type, found 'f32' |
test/cases/compile_errors/stage1/obj/prevent_bad_implicit_casting_of_anyframe_types.zig+3-3| ... | ... | @@ -19,6 +19,6 @@ fn func() void {} |
| 19 | 19 | // backend=stage1 |
| 20 | 20 | // target=native |
| 21 | 21 | // |
| 22 | // tmp.zig:3:28: error: expected type 'anyframe->i32', found 'anyframe' | |
| 23 | // tmp.zig:8:28: error: expected type 'anyframe->i32', found 'i32' | |
| 24 | // tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)' | |
| 22 | // :3:28: error: expected type 'anyframe->i32', found 'anyframe' | |
| 23 | // :8:28: error: expected type 'anyframe->i32', found 'i32' | |
| 24 | // tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)' | |
| \ No newline at end of file |
test/cases/compile_errors/stage1/obj/primitives_take_precedence_over_declarations.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const @"u8" = u16; | |
| 2 | export fn entry() void { | |
| 3 | const a: u8 = 300; | |
| 4 | _ = a; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:19: error: integer value 300 cannot be coerced to type 'u8' |
test/cases/compile_errors/stage1/obj/ptrToInt_0_to_non_optional_pointer.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var b = @intToPtr(*i32, 0); | |
| 3 | _ = b; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:13: error: pointer type '*i32' does not allow address zero |
test/cases/compile_errors/stage1/obj/ptrcast_to_non-pointer.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry(a: *i32) usize { | |
| 2 | return @ptrCast(usize, a); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:21: error: expected pointer, found 'usize' |
test/cases/compile_errors/stage1/obj/redefinition_of_enums.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const A = enum {x}; | |
| 2 | const A = enum {x}; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:2:1: error: redeclaration of 'A' | |
| 9 | // tmp.zig:1:1: note: other declaration here |
test/cases/compile_errors/stage1/obj/redefinition_of_global_variables.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | var a : i32 = 1; | |
| 2 | var a : i32 = 2; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:2:1: error: redeclaration of 'a' | |
| 9 | // tmp.zig:1:1: note: other declaration here |
test/cases/compile_errors/stage1/obj/redefinition_of_struct.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const A = struct { x : i32, }; | |
| 2 | const A = struct { y : i32, }; | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:2:1: error: redeclaration of 'A' | |
| 9 | // tmp.zig:1:1: note: other declaration here |
test/cases/compile_errors/stage1/obj/refer_to_the_type_of_a_generic_function.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const Func = fn (type) void; | |
| 3 | const f: Func = undefined; | |
| 4 | f(i32); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:4:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/referring_to_a_struct_that_is_invalid.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | const UsbDeviceRequest = struct { | |
| 2 | Type: u8, | |
| 3 | }; | |
| 4 | ||
| 5 | export fn foo() void { | |
| 6 | comptime assert(@sizeOf(UsbDeviceRequest) == 0x8); | |
| 7 | } | |
| 8 | ||
| 9 | fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:10:14: error: reached unreachable code |
test/cases/compile_errors/stage1/obj/return_from_defer_expression.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn testTrickyDefer() !void { | |
| 2 | defer canFail() catch {}; | |
| 3 | ||
| 4 | defer try canFail(); | |
| 5 | ||
| 6 | const a = maybeInt() orelse return; | |
| 7 | } | |
| 8 | ||
| 9 | fn canFail() anyerror!void { } | |
| 10 | ||
| 11 | pub fn maybeInt() ?i32 { | |
| 12 | return 0; | |
| 13 | } | |
| 14 | ||
| 15 | export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); } | |
| 16 | ||
| 17 | // error | |
| 18 | // backend=stage1 | |
| 19 | // target=native | |
| 20 | // | |
| 21 | // tmp.zig:4:11: error: 'try' not allowed inside defer expression |
test/cases/compile_errors/stage1/obj/runtime_cast_to_union_which_has_non-void_fields.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | const Letter = enum { A, B, C }; | |
| 2 | const Value = union(Letter) { | |
| 3 | A: i32, | |
| 4 | B, | |
| 5 | C, | |
| 6 | }; | |
| 7 | export fn entry() void { | |
| 8 | foo(Letter.A); | |
| 9 | } | |
| 10 | fn foo(l: Letter) void { | |
| 11 | var x: Value = l; | |
| 12 | _ = x; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage1 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // tmp.zig:11:20: error: runtime cast to union 'Value' which has non-void fields | |
| 20 | // tmp.zig:3:5: note: field 'A' has type 'i32' |
test/cases/compile_errors/stage1/obj/saturating_arithmetic_does_not_allow_floats.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | _ = @as(f32, 1.0) +| @as(f32, 1.0); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // error: invalid operands to binary expression: 'f32' and 'f32' |
test/cases/compile_errors/stage1/obj/setAlignStack_in_naked_function.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() callconv(.Naked) void { | |
| 2 | @setAlignStack(16); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: @setAlignStack in naked function |
test/cases/compile_errors/stage1/obj/setAlignStack_outside_function.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | comptime { | |
| 2 | @setAlignStack(16); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: @setAlignStack outside function |
test/cases/compile_errors/stage1/obj/setAlignStack_set_twice.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | @setAlignStack(16); | |
| 3 | @setAlignStack(16); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: alignstack set twice | |
| 11 | // tmp.zig:2:5: note: first set here |
test/cases/compile_errors/stage1/obj/setAlignStack_too_big.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | @setAlignStack(511 + 1); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: attempt to @setAlignStack(512); maximum is 256 |
test/cases/compile_errors/stage1/obj/setting_a_section_on_a_local_variable.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() i32 { | |
| 2 | var foo: i32 linksection(".text2") = 1234; | |
| 3 | return foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:30: error: cannot set section of local variable 'foo' |
test/cases/compile_errors/stage1/obj/shift_left_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a >>= 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/shift_left_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a << 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/shift_right_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a >>= 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/shift_right_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a >> 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/shifting_RHS_is_log2_of_LHS_int_bit_width.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry(x: u8, y: u8) u8 { | |
| 2 | return x << y; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:17: error: expected type 'u3', found 'u8' |
test/cases/compile_errors/stage1/obj/slicing_single-item_pointer.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry(ptr: *i32) void { | |
| 2 | const slice = ptr[0..2]; | |
| 3 | _ = slice; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:22: error: slice of single-item pointer |
test/cases/compile_errors/stage1/obj/struct_field_missing_type.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Letter = struct { | |
| 2 | A, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var a = Letter { .A = {} }; | |
| 6 | _ = a; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:2:5: error: struct field missing type |
test/cases/compile_errors/stage1/obj/struct_init_syntax_for_array.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const foo = [3]u16{ .x = 1024 }; | |
| 2 | comptime { | |
| 3 | _ = foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:1:13: error: initializing array with struct syntax |
test/cases/compile_errors/stage1/obj/struct_with_declarations_unavailable_for_reify_type.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(@typeInfo(struct { const foo = 1; })); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:15: error: Type.Struct.decls must be empty for @Type |
test/cases/compile_errors/stage1/obj/struct_with_invalid_field.zig deleted-30| ... | ... | @@ -1,30 +0,0 @@ |
| 1 | const std = @import("std",); | |
| 2 | const Allocator = std.mem.Allocator; | |
| 3 | const ArrayList = std.ArrayList; | |
| 4 | ||
| 5 | const HeaderWeight = enum { | |
| 6 | H1, H2, H3, H4, H5, H6, | |
| 7 | }; | |
| 8 | ||
| 9 | const MdText = ArrayList(u8); | |
| 10 | ||
| 11 | const MdNode = union(enum) { | |
| 12 | Header: struct { | |
| 13 | text: MdText, | |
| 14 | weight: HeaderValue, | |
| 15 | }, | |
| 16 | }; | |
| 17 | ||
| 18 | export fn entry() void { | |
| 19 | const a = MdNode.Header { | |
| 20 | .text = MdText.init(std.testing.allocator), | |
| 21 | .weight = HeaderWeight.H1, | |
| 22 | }; | |
| 23 | _ = a; | |
| 24 | } | |
| 25 | ||
| 26 | // error | |
| 27 | // backend=stage1 | |
| 28 | // target=native | |
| 29 | // | |
| 30 | // tmp.zig:14:17: error: use of undeclared identifier 'HeaderValue' |
test/cases/compile_errors/stage1/obj/sub_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a -= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/sub_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a - a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/sub_wrap_assign_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a -%= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/sub_wrap_on_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a -% a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/suspend_inside_suspend_block.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = async foo(); | |
| 3 | } | |
| 4 | fn foo() void { | |
| 5 | suspend { | |
| 6 | suspend { | |
| 7 | } | |
| 8 | } | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // tmp.zig:6:9: error: cannot suspend inside suspend block | |
| 16 | // tmp.zig:5:5: note: other suspend block here |
test/cases/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong.zig deleted-24| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | const Number = enum { | |
| 2 | One, | |
| 3 | Two, | |
| 4 | Three, | |
| 5 | Four, | |
| 6 | }; | |
| 7 | fn f(n: Number) i32 { | |
| 8 | switch (n) { | |
| 9 | Number.One => 1, | |
| 10 | Number.Two => 2, | |
| 11 | Number.Three => @as(i32, 3), | |
| 12 | Number.Four => 4, | |
| 13 | Number.Two => 2, | |
| 14 | } | |
| 15 | } | |
| 16 | ||
| 17 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 18 | ||
| 19 | // error | |
| 20 | // backend=stage1 | |
| 21 | // target=native | |
| 22 | // | |
| 23 | // tmp.zig:13:15: error: duplicate switch value | |
| 24 | // tmp.zig:10:15: note: other value here |
test/cases/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong_when_else_present.zig deleted-25| ... | ... | @@ -1,25 +0,0 @@ |
| 1 | const Number = enum { | |
| 2 | One, | |
| 3 | Two, | |
| 4 | Three, | |
| 5 | Four, | |
| 6 | }; | |
| 7 | fn f(n: Number) i32 { | |
| 8 | switch (n) { | |
| 9 | Number.One => 1, | |
| 10 | Number.Two => 2, | |
| 11 | Number.Three => @as(i32, 3), | |
| 12 | Number.Four => 4, | |
| 13 | Number.Two => 2, | |
| 14 | else => 10, | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| 18 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage1 | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // tmp.zig:13:15: error: duplicate switch value | |
| 25 | // tmp.zig:10:15: note: other value here |
test/cases/compile_errors/stage1/obj/switch_expression-duplicate_type.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | fn foo(comptime T: type, x: T) u8 { | |
| 2 | _ = x; | |
| 3 | return switch (T) { | |
| 4 | u32 => 0, | |
| 5 | u64 => 1, | |
| 6 | u32 => 2, | |
| 7 | else => 3, | |
| 8 | }; | |
| 9 | } | |
| 10 | export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:6:9: error: duplicate switch value | |
| 17 | // tmp.zig:4:9: note: previous value here |
test/cases/compile_errors/stage1/obj/switch_expression-duplicate_type_struct_alias.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | const Test = struct { | |
| 2 | bar: i32, | |
| 3 | }; | |
| 4 | const Test2 = Test; | |
| 5 | fn foo(comptime T: type, x: T) u8 { | |
| 6 | _ = x; | |
| 7 | return switch (T) { | |
| 8 | Test => 0, | |
| 9 | u64 => 1, | |
| 10 | Test2 => 2, | |
| 11 | else => 3, | |
| 12 | }; | |
| 13 | } | |
| 14 | export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage1 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // tmp.zig:10:9: error: duplicate switch value | |
| 21 | // tmp.zig:8:9: note: previous value here |
test/cases/compile_errors/stage1/obj/switch_expression-missing_enumeration_prong.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | const Number = enum { | |
| 2 | One, | |
| 3 | Two, | |
| 4 | Three, | |
| 5 | Four, | |
| 6 | }; | |
| 7 | fn f(n: Number) i32 { | |
| 8 | switch (n) { | |
| 9 | Number.One => 1, | |
| 10 | Number.Two => 2, | |
| 11 | Number.Three => @as(i32, 3), | |
| 12 | } | |
| 13 | } | |
| 14 | ||
| 15 | export fn entry() usize { return @sizeOf(@TypeOf(f)); } | |
| 16 | ||
| 17 | // error | |
| 18 | // backend=stage1 | |
| 19 | // target=native | |
| 20 | // | |
| 21 | // tmp.zig:8:5: error: enumeration value 'Number.Four' not handled in switch |
test/cases/compile_errors/stage1/obj/switch_expression-multiple_else_prongs.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | fn f(x: u32) void { | |
| 2 | const value: bool = switch (x) { | |
| 3 | 1234 => false, | |
| 4 | else => true, | |
| 5 | else => true, | |
| 6 | }; | |
| 7 | } | |
| 8 | export fn entry() void { | |
| 9 | f(1234); | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:5:9: error: multiple else prongs in switch expression |
test/cases/compile_errors/stage1/obj/switch_expression-non_exhaustive_integer_prongs.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | fn foo(x: u8) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | } | |
| 5 | } | |
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:2:5: error: switch must handle all possibilities |
test/cases/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_enum.zig deleted-24| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | const TestEnum = enum{ T1, T2 }; | |
| 2 | ||
| 3 | fn err(x: u8) TestEnum { | |
| 4 | switch (x) { | |
| 5 | 0 => return TestEnum.T1, | |
| 6 | else => return TestEnum.T2, | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | fn foo(x: u8) void { | |
| 11 | switch (err(x)) { | |
| 12 | TestEnum.T1 => {}, | |
| 13 | TestEnum.T2 => {}, | |
| 14 | else => {}, | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| 18 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage1 | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // tmp.zig:14:9: error: unreachable else prong, all cases already handled |
test/cases/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_i8.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | fn foo(x: i8) void { | |
| 2 | switch (x) { | |
| 3 | -128...0 => {}, | |
| 4 | 1 => {}, | |
| 5 | 2 => {}, | |
| 6 | 3 => {}, | |
| 7 | 4...127 => {}, | |
| 8 | else => {}, | |
| 9 | } | |
| 10 | } | |
| 11 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:8:9: error: unreachable else prong, all cases already handled |
test/cases/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_u8.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | fn foo(x: u8) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | 1 => {}, | |
| 5 | 2 => {}, | |
| 6 | 3 => {}, | |
| 7 | 4...255 => {}, | |
| 8 | else => {}, | |
| 9 | } | |
| 10 | } | |
| 11 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // tmp.zig:8:9: error: unreachable else prong, all cases already handled |
test/cases/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u1.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | fn foo(x: u1) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | 1 => {}, | |
| 5 | else => {}, | |
| 6 | } | |
| 7 | } | |
| 8 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // tmp.zig:5:9: error: unreachable else prong, all cases already handled |
test/cases/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u2.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | fn foo(x: u2) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | 1 => {}, | |
| 5 | 2 => {}, | |
| 6 | 3 => {}, | |
| 7 | else => {}, | |
| 8 | } | |
| 9 | } | |
| 10 | export fn entry() usize { return @sizeOf(@TypeOf(foo)); } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:7:9: error: unreachable else prong, all cases already handled |
test/cases/compile_errors/stage1/obj/switch_on_enum_with_1_field_with_no_prongs.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Foo = enum { M }; | |
| 2 | ||
| 3 | export fn entry() void { | |
| 4 | var f = Foo.M; | |
| 5 | switch (f) {} | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:5:5: error: enumeration value 'Foo.M' not handled in switch |
test/cases/compile_errors/stage1/obj/threadlocal_qualifier_on_const.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | threadlocal const x: i32 = 1234; | |
| 2 | export fn entry() i32 { | |
| 3 | return x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:1:1: error: threadlocal variable cannot be constant |
test/cases/compile_errors/stage1/obj/truncate_sign_mismatch.zig deleted-25| ... | ... | @@ -1,25 +0,0 @@ |
| 1 | export fn entry1() i8 { | |
| 2 | var x: u32 = 10; | |
| 3 | return @truncate(i8, x); | |
| 4 | } | |
| 5 | export fn entry2() u8 { | |
| 6 | var x: i32 = -10; | |
| 7 | return @truncate(u8, x); | |
| 8 | } | |
| 9 | export fn entry3() i8 { | |
| 10 | comptime var x: u32 = 10; | |
| 11 | return @truncate(i8, x); | |
| 12 | } | |
| 13 | export fn entry4() u8 { | |
| 14 | comptime var x: i32 = -10; | |
| 15 | return @truncate(u8, x); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage1 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // tmp.zig:3:26: error: expected signed integer type, found 'u32' | |
| 23 | // tmp.zig:7:26: error: expected unsigned integer type, found 'i32' | |
| 24 | // tmp.zig:11:26: error: expected signed integer type, found 'u32' | |
| 25 | // tmp.zig:15:26: error: expected unsigned integer type, found 'i32' |
test/cases/compile_errors/stage1/obj/truncate_undefined_value.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var z = @truncate(u8, @as(u16, undefined)); | |
| 3 | _ = z; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:27: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/try_in_function_with_non_error_return_type.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | try something(); | |
| 3 | } | |
| 4 | fn something() anyerror!void { } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:5: error: expected type 'void', found 'anyerror' |
test/cases/compile_errors/stage1/obj/type_variables_must_be_constant.zig+1-1| ... | ... | @@ -7,4 +7,4 @@ export fn entry() foo { |
| 7 | 7 | // backend=stage1 |
| 8 | 8 | // target=native |
| 9 | 9 | // |
| 10 | // tmp.zig:1:1: error: variable of type 'type' must be constant | |
| 10 | // :1:1: error: variable of type 'type' must be constant |
test/cases/compile_errors/stage1/obj/undeclared_identifier.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | return | |
| 3 | b + | |
| 4 | c; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/stage1/obj/undeclared_identifier_error_should_mark_fn_as_impure.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | test_a_thing(); | |
| 3 | } | |
| 4 | fn test_a_thing() void { | |
| 5 | bad_fn_call(); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:5:5: error: use of undeclared identifier 'bad_fn_call' |
test/cases/compile_errors/stage1/obj/undeclared_identifier_in_unanalyzed_branch.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | if (false) { | |
| 3 | lol_this_doesnt_exist = nonsense; | |
| 4 | } | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:9: error: use of undeclared identifier 'lol_this_doesnt_exist' |
test/cases/compile_errors/stage1/obj/undefined_as_field_type_is_rejected.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | const Foo = struct { | |
| 2 | a: undefined, | |
| 3 | }; | |
| 4 | export fn entry1() void { | |
| 5 | const foo: Foo = undefined; | |
| 6 | _ = foo; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:2:8: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/obj/undefined_function_call.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | b(); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/stage1/obj/underscore_is_not_a_declarable_symbol.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f1() usize { | |
| 2 | var _: usize = 2; | |
| 3 | return _; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:9: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_for.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn returns() void { | |
| 2 | for ([_]void{}) |_, i| { | |
| 3 | for ([_]void{}) |_, j| { | |
| 4 | return _; | |
| 5 | } | |
| 6 | } | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:4:20: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn returns() void { | |
| 2 | while (optionalReturn()) |_| { | |
| 3 | while (optionalReturn()) |_| { | |
| 4 | return _; | |
| 5 | } | |
| 6 | } | |
| 7 | } | |
| 8 | fn optionalReturn() ?u32 { | |
| 9 | return 1; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage1 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // tmp.zig:4:20: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while_else.zig deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | export fn returns() void { | |
| 2 | while (optionalReturnError()) |_| { | |
| 3 | while (optionalReturnError()) |_| { | |
| 4 | return; | |
| 5 | } else |_| { | |
| 6 | if (_ == error.optionalReturnError) return; | |
| 7 | } | |
| 8 | } | |
| 9 | } | |
| 10 | fn optionalReturnError() !?u32 { | |
| 11 | return error.optionalReturnError; | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage1 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // tmp.zig:6:17: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/stage1/obj/union_fields_with_value_assignments.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const MultipleChoice = union { | |
| 2 | A: i32 = 20, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var x: MultipleChoice = undefined; | |
| 6 | _ = x; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // tmp.zig:1:24: error: explicitly valued tagged union missing integer tag type | |
| 14 | // tmp.zig:2:14: note: tag value specified here |
test/cases/compile_errors/stage1/obj/union_with_0_fields.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | const Foo = union {}; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:13: error: union declarations must have at least one tag |
test/cases/compile_errors/stage1/obj/union_with_specified_enum_omits_field.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | const Letter = enum { | |
| 2 | A, | |
| 3 | B, | |
| 4 | C, | |
| 5 | }; | |
| 6 | const Payload = union(Letter) { | |
| 7 | A: i32, | |
| 8 | B: f64, | |
| 9 | }; | |
| 10 | export fn entry() usize { | |
| 11 | return @sizeOf(Payload); | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage1 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // tmp.zig:6:17: error: enum field missing: 'C' | |
| 19 | // tmp.zig:4:5: note: declared here |
test/cases/compile_errors/stage1/obj/unreachable_code-double_break.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | const b = blk: { | |
| 3 | break :blk break :blk @as(u32, 1); | |
| 4 | }; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:9: error: unreachable code | |
| 12 | // tmp.zig:3:20: note: control flow is diverted here |
test/cases/compile_errors/stage1/obj/unreachable_code-nested_returns.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn a() i32 { | |
| 2 | return return 1; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: unreachable code | |
| 10 | // tmp.zig:2:12: note: control flow is diverted here |
test/cases/compile_errors/stage1/obj/unreachable_code.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn a() void { | |
| 2 | return; | |
| 3 | b(); | |
| 4 | } | |
| 5 | ||
| 6 | fn b() void {} | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // tmp.zig:3:6: error: unreachable code | |
| 13 | // tmp.zig:2:5: note: control flow is diverted here |
test/cases/compile_errors/stage1/obj/unreachable_variable.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | const a: noreturn = {}; | |
| 3 | _ = a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:25: error: expected type 'noreturn', found 'void' |
test/cases/compile_errors/stage1/obj/unreachable_with_return.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | fn a() noreturn {return;} | |
| 2 | export fn entry() void { a(); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage1 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // tmp.zig:1:18: error: expected type 'noreturn', found 'void' |
test/cases/compile_errors/stage1/obj/use_invalid_number_literal_as_array_index.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | var v = 25; | |
| 2 | export fn entry() void { | |
| 3 | var arr: [v]u8 = undefined; | |
| 4 | _ = arr; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:1:1: error: unable to infer variable type |
test/cases/compile_errors/stage1/obj/use_of_undeclared_identifier.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn f() void { | |
| 2 | b = 3; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/stage1/obj/using_invalid_types_in_function_call_raises_an_error.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const MenuEffect = enum {}; | |
| 2 | fn func(effect: MenuEffect) void { _ = effect; } | |
| 3 | export fn entry() void { | |
| 4 | func(MenuEffect.ThisDoesNotExist); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:1:20: error: enum declarations must have at least one tag |
test/cases/compile_errors/stage1/obj/usingnamespace_with_wrong_type.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | usingnamespace void; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // tmp.zig:1:1: error: expected struct, enum, or union; found 'void' |
test/cases/compile_errors/stage1/obj/variable_has_wrong_type.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn f() i32 { | |
| 2 | const a = "a"; | |
| 3 | return a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:12: error: expected type 'i32', found '*const [1:0]u8' |
test/cases/compile_errors/stage1/obj/variable_initialization_compile_error_then_referenced.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | fn Undeclared() type { | |
| 2 | return T; | |
| 3 | } | |
| 4 | fn Gen() type { | |
| 5 | const X = Undeclared(); | |
| 6 | return struct { | |
| 7 | x: X, | |
| 8 | }; | |
| 9 | } | |
| 10 | export fn entry() void { | |
| 11 | const S = Gen(); | |
| 12 | _ = S; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage1 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // tmp.zig:2:12: error: use of undeclared identifier 'T' |
test/cases/compile_errors/stage1/obj/variable_with_type_noreturn.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry9() void { | |
| 2 | var z: noreturn = return; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:5: error: unreachable code | |
| 10 | // tmp.zig:2:23: note: control flow is diverted here |
test/cases/compile_errors/stage1/obj/volatile_on_global_assembly.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | comptime { | |
| 2 | asm volatile (""); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:9: error: volatile is meaningless on global assembly |
test/cases/compile_errors/stage1/obj/while_expected_bool_got_error_union.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | while (bar()) {} | |
| 3 | } | |
| 4 | fn bar() anyerror!i32 { return 1; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:15: error: expected type 'bool', found 'anyerror!i32' |
test/cases/compile_errors/stage1/obj/while_expected_bool_got_optional.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | while (bar()) {} | |
| 3 | } | |
| 4 | fn bar() ?i32 { return 1; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:15: error: expected type 'bool', found '?i32' |
test/cases/compile_errors/stage1/obj/write_to_const_global_variable.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const x : i32 = 99; | |
| 2 | fn f() void { | |
| 3 | x = 1; | |
| 4 | } | |
| 5 | export fn entry() void { f(); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:9: error: cannot assign to constant |
test/cases/compile_errors/stage1/obj/wrong_size_to_an_array_literal.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | const array = [2]u8{1, 2, 3}; | |
| 3 | _ = array; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:31: error: index 2 outside array of size 2 |
test/cases/compile_errors/stage1/obj/wrong_type_passed_to_panic.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var e = error.Foo; | |
| 3 | @panic(e); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:12: error: expected type '[]const u8', found 'error{Foo}' |
test/cases/compile_errors/stage1/obj/wrong_type_to_hasField.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | export fn entry() bool { | |
| 2 | return @hasField(i32, "hi"); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // tmp.zig:2:22: error: type 'i32' does not support @hasField |
test/cases/compile_errors/stage1/or_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: bool = undefined; | |
| 3 | _ = a or a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/orelse_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: ?bool = undefined; | |
| 3 | _ = a orelse false; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:11: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/ptrToInt_with_pointer_to_zero-sized_type.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | var pointer: ?*u0 = null; | |
| 3 | var x = @ptrToInt(pointer); | |
| 4 | _ = x; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // tmp.zig:3:23: error: pointer to size 0 type has no address |
test/cases/compile_errors/stage1/shift_left_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a >>= 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/shift_left_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a << 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/shift_right_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a >>= 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/shift_right_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a >> 2; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/sub_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a -= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/sub_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a - a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/sub_wrap_assign_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | a -%= a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:5: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/sub_wrap_on_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var a: i64 = undefined; | |
| 3 | _ = a -% a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:3:9: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/stage1/test/access_invalid_typeInfo_decl.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const A = B; | |
| 2 | test "Crash" { | |
| 3 | _ = @typeInfo(@This()).Struct.decls[0]; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // tmp.zig:1:11: error: use of undeclared identifier 'B' |
test/cases/compile_errors/stage1/test/alignCast_of_zero_sized_types.zig deleted-28| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | const a: *void = undefined; | |
| 3 | _ = @alignCast(2, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | const a: ?*void = undefined; | |
| 7 | _ = @alignCast(2, a); | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | const a: []void = undefined; | |
| 11 | _ = @alignCast(2, a); | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | const a = struct { | |
| 15 | fn a(comptime b: u32) void { _ = b; } | |
| 16 | }.a; | |
| 17 | _ = @alignCast(2, a); | |
| 18 | } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage1 | |
| 22 | // target=native | |
| 23 | // is_test=1 | |
| 24 | // | |
| 25 | // tmp.zig:3:23: error: cannot adjust alignment of zero sized type '*void' | |
| 26 | // tmp.zig:7:23: error: cannot adjust alignment of zero sized type '?*void' | |
| 27 | // tmp.zig:11:23: error: cannot adjust alignment of zero sized type '[]void' | |
| 28 | // tmp.zig:17:23: error: cannot adjust alignment of zero sized type 'fn(u32) anytype' |
test/cases/compile_errors/stage1/test/bad_splat_type.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const c = 4; | |
| 3 | var v = @splat(4, c); | |
| 4 | _ = v; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // is_test=1 | |
| 11 | // | |
| 12 | // tmp.zig:3:23: error: vector element type must be integer, float, bool, or pointer; 'comptime_int' is invalid |
test/cases/compile_errors/stage1/test/binary_OR_operator_on_error_sets.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub const A = error.A; | |
| 2 | pub const AB = A | error.B; | |
| 3 | export fn entry() void { | |
| 4 | var x: AB = undefined; | |
| 5 | _ = x; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}' |
test/cases/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-always_inline.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var call_me: fn () void = undefined; | |
| 3 | @call(.{ .modifier = .always_inline }, call_me, .{}); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // tmp.zig:3:5: error: the specified modifier requires a comptime-known function |
test/cases/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-compile_time.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var call_me: fn () void = undefined; | |
| 3 | @call(.{ .modifier = .compile_time }, call_me, .{}); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // tmp.zig:3:5: error: the specified modifier requires a comptime-known function |
test/cases/compile_errors/stage1/test/combination_of_nosuspend_and_async.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | nosuspend { | |
| 3 | const bar = async foo(); | |
| 4 | suspend {} | |
| 5 | resume bar; | |
| 6 | } | |
| 7 | } | |
| 8 | fn foo() void {} | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // is_test=1 | |
| 14 | // | |
| 15 | // tmp.zig:4:9: error: suspend inside nosuspend block | |
| 16 | // tmp.zig:2:5: note: nosuspend block here |
test/cases/compile_errors/stage1/test/comparison_of_non-tagged_union_and_enum_literal.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const U = union { A: u32, B: u64 }; | |
| 3 | var u = U{ .A = 42 }; | |
| 4 | var ok = u == .A; | |
| 5 | _ = ok; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:4:16: error: comparison of union and enum literal is only valid for tagged union types | |
| 14 | // tmp.zig:2:15: note: type U is not a tagged union |
test/cases/compile_errors/stage1/test/comptime_vector_overflow_shows_the_index.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | comptime { | |
| 2 | var a: @import("std").meta.Vector(4, u8) = [_]u8{ 1, 2, 255, 4 }; | |
| 3 | var b: @import("std").meta.Vector(4, u8) = [_]u8{ 5, 6, 1, 8 }; | |
| 4 | var x = a + b; | |
| 5 | _ = x; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:4:15: error: operation caused overflow | |
| 14 | // tmp.zig:4:15: note: when computing vector element at index 2 |
test/cases/compile_errors/stage1/test/error_in_struct_initializer_doesnt_crash_the_compiler.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub export fn entry() void { | |
| 2 | const bitfield = struct { | |
| 3 | e: u8, | |
| 4 | e: u8, | |
| 5 | }; | |
| 6 | var a = .{@sizeOf(bitfield)}; | |
| 7 | _ = a; | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // is_test=1 | |
| 14 | // | |
| 15 | // tmp.zig:4:9: error: duplicate struct field: 'e' |
test/cases/compile_errors/stage1/test/errors_in_for_loop_bodies_are_propagated.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var arr: [100]u8 = undefined; | |
| 3 | for (arr) |bits| _ = @popCount(bits); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // tmp.zig:3:26: error: expected 2 arguments, found 1 |
test/cases/compile_errors/stage1/test/export_with_empty_name_string.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub export fn entry() void { } | |
| 2 | comptime { | |
| 3 | @export(entry, .{ .name = "" }); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // tmp.zig:3:5: error: exported symbol name cannot be empty |
test/cases/compile_errors/stage1/test/int-float_conversion_to_comptime_int-float.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: f32 = 2; | |
| 3 | _ = @floatToInt(comptime_int, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var a: u32 = 2; | |
| 7 | _ = @intToFloat(comptime_float, a); | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // is_test=1 | |
| 14 | // | |
| 15 | // tmp.zig:3:35: error: unable to evaluate constant expression | |
| 16 | // tmp.zig:7:37: error: unable to evaluate constant expression |
test/cases/compile_errors/stage1/test/invalid_assignments.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | export fn entry1() void { | |
| 2 | var a: []const u8 = "foo"; | |
| 3 | a[0..2] = "bar"; | |
| 4 | } | |
| 5 | export fn entry2() void { | |
| 6 | var a: u8 = 2; | |
| 7 | a + 2 = 3; | |
| 8 | } | |
| 9 | export fn entry4() void { | |
| 10 | 2 + 2 = 3; | |
| 11 | } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // is_test=1 | |
| 17 | // | |
| 18 | // tmp.zig:3:6: error: invalid left-hand side to assignment | |
| 19 | // tmp.zig:7:7: error: invalid left-hand side to assignment | |
| 20 | // tmp.zig:10:7: error: invalid left-hand side to assignment |
test/cases/compile_errors/stage1/test/invalid_float_casts.zig deleted-26| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: f32 = 2; | |
| 3 | _ = @floatCast(comptime_float, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var a: f32 = 2; | |
| 7 | _ = @floatToInt(f32, a); | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | var a: f32 = 2; | |
| 11 | _ = @intToFloat(f32, a); | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | var a: u32 = 2; | |
| 15 | _ = @floatCast(f32, a); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage1 | |
| 20 | // target=native | |
| 21 | // is_test=1 | |
| 22 | // | |
| 23 | // tmp.zig:3:36: error: unable to evaluate constant expression | |
| 24 | // tmp.zig:7:21: error: expected integer type, found 'f32' | |
| 25 | // tmp.zig:11:26: error: expected int type, found 'f32' | |
| 26 | // tmp.zig:15:25: error: expected float type, found 'u32' |
test/cases/compile_errors/stage1/test/invalid_int_casts.zig deleted-26| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: u32 = 2; | |
| 3 | _ = @intCast(comptime_int, a); | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var a: u32 = 2; | |
| 7 | _ = @intToFloat(u32, a); | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | var a: u32 = 2; | |
| 11 | _ = @floatToInt(u32, a); | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | var a: f32 = 2; | |
| 15 | _ = @intCast(u32, a); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage1 | |
| 20 | // target=native | |
| 21 | // is_test=1 | |
| 22 | // | |
| 23 | // tmp.zig:3:32: error: unable to evaluate constant expression | |
| 24 | // tmp.zig:7:21: error: expected float type, found 'u32' | |
| 25 | // tmp.zig:11:26: error: expected float type, found 'u32' | |
| 26 | // tmp.zig:15:23: error: expected integer type, found 'f32' |
test/cases/compile_errors/stage1/test/invalid_non-exhaustive_enum_to_union.zig deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | const E = enum(u8) { | |
| 2 | a, | |
| 3 | b, | |
| 4 | _, | |
| 5 | }; | |
| 6 | const U = union(E) { | |
| 7 | a, | |
| 8 | b, | |
| 9 | }; | |
| 10 | export fn foo() void { | |
| 11 | var e = @intToEnum(E, 15); | |
| 12 | var u: U = e; | |
| 13 | _ = u; | |
| 14 | } | |
| 15 | export fn bar() void { | |
| 16 | const e = @intToEnum(E, 15); | |
| 17 | var u: U = e; | |
| 18 | _ = u; | |
| 19 | } | |
| 20 | ||
| 21 | // error | |
| 22 | // backend=stage1 | |
| 23 | // target=native | |
| 24 | // is_test=1 | |
| 25 | // | |
| 26 | // tmp.zig:12:16: error: runtime cast to union 'U' from non-exhaustive enum | |
| 27 | // tmp.zig:17:16: error: no tag by value 15 |
test/cases/compile_errors/stage1/test/invalid_pointer_with_reify_type.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(.{ .Pointer = .{ | |
| 3 | .size = .One, | |
| 4 | .is_const = false, | |
| 5 | .is_volatile = false, | |
| 6 | .alignment = 1, | |
| 7 | .address_space = .generic, | |
| 8 | .child = u8, | |
| 9 | .is_allowzero = false, | |
| 10 | .sentinel = &@as(u8, 0), | |
| 11 | }}); | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage1 | |
| 16 | // target=native | |
| 17 | // is_test=1 | |
| 18 | // | |
| 19 | // tmp.zig:2:16: error: sentinels are only allowed on slices and unknown-length pointers |
test/cases/compile_errors/stage1/test/nested_vectors.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const V1 = @import("std").meta.Vector(4, u8); | |
| 3 | const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } }); | |
| 4 | var v: V2 = undefined; | |
| 5 | _ = v; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:3:23: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid |
test/cases/compile_errors/stage1/test/non-exhaustive_enum_marker_assigned_a_value.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | const A = enum { | |
| 2 | a, | |
| 3 | b, | |
| 4 | _ = 1, | |
| 5 | }; | |
| 6 | const B = enum { | |
| 7 | a, | |
| 8 | b, | |
| 9 | _, | |
| 10 | }; | |
| 11 | comptime { _ = A; _ = B; } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage1 | |
| 15 | // target=native | |
| 16 | // is_test=1 | |
| 17 | // | |
| 18 | // tmp.zig:4:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value | |
| 19 | // tmp.zig:6:11: error: non-exhaustive enum missing integer tag type | |
| 20 | // tmp.zig:9:5: note: marked non-exhaustive here |
test/cases/compile_errors/stage1/test/non-exhaustive_enums.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | const B = enum(u1) { | |
| 2 | a, | |
| 3 | _, | |
| 4 | b, | |
| 5 | }; | |
| 6 | const C = enum(u1) { | |
| 7 | a, | |
| 8 | b, | |
| 9 | _, | |
| 10 | }; | |
| 11 | pub export fn entry() void { | |
| 12 | _ = B; | |
| 13 | _ = C; | |
| 14 | } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage1 | |
| 18 | // target=native | |
| 19 | // is_test=1 | |
| 20 | // | |
| 21 | // tmp.zig:3:5: error: '_' field of non-exhaustive enum must be last | |
| 22 | // tmp.zig:6:11: error: non-exhaustive enum specifies every value |
test/cases/compile_errors/stage1/test/not_an_enum_type.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var self: Error = undefined; | |
| 3 | switch (self) { | |
| 4 | InvalidToken => |x| return x.token, | |
| 5 | ExpectedVarDeclOrFn => |x| return x.token, | |
| 6 | } | |
| 7 | } | |
| 8 | const Error = union(enum) { | |
| 9 | A: InvalidToken, | |
| 10 | B: ExpectedVarDeclOrFn, | |
| 11 | }; | |
| 12 | const InvalidToken = struct {}; | |
| 13 | const ExpectedVarDeclOrFn = struct {}; | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage1 | |
| 17 | // target=native | |
| 18 | // is_test=1 | |
| 19 | // | |
| 20 | // tmp.zig:4:9: error: expected type '@typeInfo(Error).Union.tag_type.?', found 'type' |
test/cases/compile_errors/stage1/test/ptrToInt_with_pointer_to_zero-sized_type.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var pointer: ?*u0 = null; | |
| 3 | var x = @ptrToInt(pointer); | |
| 4 | _ = x; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // is_test=1 | |
| 11 | // | |
| 12 | // tmp.zig:3:23: error: pointer to size 0 type has no address |
test/cases/compile_errors/stage1/test/reassign_to_array_parameter.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | fn reassign(a: [3]f32) void { | |
| 2 | a = [3]f32{4, 5, 6}; | |
| 3 | } | |
| 4 | export fn entry() void { | |
| 5 | reassign(.{1, 2, 3}); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:2:15: error: cannot assign to constant |
test/cases/compile_errors/stage1/test/reassign_to_slice_parameter.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub fn reassign(s: []const u8) void { | |
| 2 | s = s[0..]; | |
| 3 | } | |
| 4 | export fn entry() void { | |
| 5 | reassign("foo"); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:2:10: error: cannot assign to constant |
test/cases/compile_errors/stage1/test/reassign_to_struct_parameter.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | const S = struct { | |
| 2 | x: u32, | |
| 3 | }; | |
| 4 | fn reassign(s: S) void { | |
| 5 | s = S{.x = 2}; | |
| 6 | } | |
| 7 | export fn entry() void { | |
| 8 | reassign(S{.x = 3}); | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=stage1 | |
| 13 | // target=native | |
| 14 | // is_test=1 | |
| 15 | // | |
| 16 | // tmp.zig:5:10: error: cannot assign to constant |
test/cases/compile_errors/stage1/test/reference_to_const_data.zig deleted-30| ... | ... | @@ -1,30 +0,0 @@ |
| 1 | export fn foo() void { | |
| 2 | var ptr = &[_]u8{0,0,0,0}; | |
| 3 | ptr[1] = 2; | |
| 4 | } | |
| 5 | export fn bar() void { | |
| 6 | var ptr = &@as(u32, 2); | |
| 7 | ptr.* = 2; | |
| 8 | } | |
| 9 | export fn baz() void { | |
| 10 | var ptr = &true; | |
| 11 | ptr.* = false; | |
| 12 | } | |
| 13 | export fn qux() void { | |
| 14 | const S = struct{ | |
| 15 | x: usize, | |
| 16 | y: usize, | |
| 17 | }; | |
| 18 | var ptr = &S{.x=1,.y=2}; | |
| 19 | ptr.x = 2; | |
| 20 | } | |
| 21 | ||
| 22 | // error | |
| 23 | // backend=stage1 | |
| 24 | // target=native | |
| 25 | // is_test=1 | |
| 26 | // | |
| 27 | // tmp.zig:3:14: error: cannot assign to constant | |
| 28 | // tmp.zig:7:13: error: cannot assign to constant | |
| 29 | // tmp.zig:11:13: error: cannot assign to constant | |
| 30 | // tmp.zig:19:13: error: cannot assign to constant |
test/cases/compile_errors/stage1/test/reify_typeOf_with_incompatible_arguments.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | var var_1: f32 = undefined; | |
| 3 | var var_2: u32 = undefined; | |
| 4 | _ = @TypeOf(var_1, var_2); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage1 | |
| 9 | // target=native | |
| 10 | // is_test=1 | |
| 11 | // | |
| 12 | // tmp.zig:4:9: error: incompatible types: 'f32' and 'u32' |
test/cases/compile_errors/stage1/test/reify_typeOf_with_no_arguments.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @TypeOf(); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // is_test=1 | |
| 9 | // | |
| 10 | // tmp.zig:2:9: error: expected at least 1 argument, found 0 |
test/cases/compile_errors/stage1/test/reject_extern_function_definitions_with_body.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | extern "c" fn definitelyNotInLibC(a: i32, b: i32) i32 { | |
| 2 | return a + b; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage1 | |
| 7 | // target=native | |
| 8 | // is_test=1 | |
| 9 | // | |
| 10 | // tmp.zig:1:1: error: extern functions have no body |
test/cases/compile_errors/stage1/test/reject_extern_variables_with_initializers.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | extern var foo: int = 2; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // is_test=1 | |
| 7 | // | |
| 8 | // tmp.zig:1:23: error: extern variables have no initializers |
test/cases/compile_errors/stage1/test/repeated_invalid_field_access_to_generic_function_returning_type_crashes_compiler_2655.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | pub fn A() type { | |
| 2 | return Q; | |
| 3 | } | |
| 4 | test "1" { | |
| 5 | _ = A().a; | |
| 6 | _ = A().a; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // is_test=1 | |
| 13 | // | |
| 14 | // tmp.zig:2:12: error: use of undeclared identifier 'Q' |
test/cases/compile_errors/stage1/test/return_invalid_type_from_test.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | test "example" { return 1; } | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // is_test=1 | |
| 7 | // | |
| 8 | // tmp.zig:1:25: error: expected type 'void', found 'comptime_int' |
test/cases/compile_errors/stage1/test/shift_on_type_with_non-power-of-two_size.zig deleted-34| ... | ... | @@ -1,34 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const S = struct { | |
| 3 | fn a() void { | |
| 4 | var x: u24 = 42; | |
| 5 | _ = x >> 24; | |
| 6 | } | |
| 7 | fn b() void { | |
| 8 | var x: u24 = 42; | |
| 9 | _ = x << 24; | |
| 10 | } | |
| 11 | fn c() void { | |
| 12 | var x: u24 = 42; | |
| 13 | _ = @shlExact(x, 24); | |
| 14 | } | |
| 15 | fn d() void { | |
| 16 | var x: u24 = 42; | |
| 17 | _ = @shrExact(x, 24); | |
| 18 | } | |
| 19 | }; | |
| 20 | S.a(); | |
| 21 | S.b(); | |
| 22 | S.c(); | |
| 23 | S.d(); | |
| 24 | } | |
| 25 | ||
| 26 | // error | |
| 27 | // backend=stage1 | |
| 28 | // target=native | |
| 29 | // is_test=1 | |
| 30 | // | |
| 31 | // tmp.zig:5:19: error: RHS of shift is too large for LHS type | |
| 32 | // tmp.zig:9:19: error: RHS of shift is too large for LHS type | |
| 33 | // tmp.zig:13:17: error: RHS of shift is too large for LHS type | |
| 34 | // tmp.zig:17:17: error: RHS of shift is too large for LHS type |
test/cases/compile_errors/stage1/test/shuffle_with_selected_index_past_first_vector_length.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | const v: @import("std").meta.Vector(4, u32) = [4]u32{ 10, 11, 12, 13 }; | |
| 3 | const x: @import("std").meta.Vector(4, u32) = [4]u32{ 14, 15, 16, 17 }; | |
| 4 | var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 }); | |
| 5 | _ = z; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage1 | |
| 10 | // target=native | |
| 11 | // is_test=1 | |
| 12 | // | |
| 13 | // tmp.zig:4:39: error: mask index '4' has out-of-bounds selection | |
| 14 | // tmp.zig:4:27: note: selected index '7' out of bounds of @Vector(4, u32) | |
| 15 | // tmp.zig:4:30: note: selections from the second vector are specified with negative numbers |
test/cases/compile_errors/stage1/test/switch_ranges_endpoints_are_validated.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | pub export fn entry() void { | |
| 2 | var x: i32 = 0; | |
| 3 | switch (x) { | |
| 4 | 6...1 => {}, | |
| 5 | -1...-5 => {}, | |
| 6 | else => unreachable, | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage1 | |
| 12 | // target=native | |
| 13 | // is_test=1 | |
| 14 | // | |
| 15 | // tmp.zig:4:9: error: range start value is greater than the end value | |
| 16 | // tmp.zig:5:9: error: range start value is greater than the end value |
test/cases/compile_errors/stage1/test/switching_with_exhaustive_enum_has___prong_.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | const E = enum{ | |
| 2 | a, | |
| 3 | b, | |
| 4 | }; | |
| 5 | pub export fn entry() void { | |
| 6 | var e: E = .b; | |
| 7 | switch (e) { | |
| 8 | .a => {}, | |
| 9 | .b => {}, | |
| 10 | _ => {}, | |
| 11 | } | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage1 | |
| 16 | // target=native | |
| 17 | // is_test=1 | |
| 18 | // | |
| 19 | // tmp.zig:7:5: error: switch on exhaustive enum has `_` prong |
test/cases/compile_errors/stage1/test/tagName_on_invalid_value_of_non-exhaustive_enum.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | test "enum" { | |
| 2 | const E = enum(u8) {A, B, _}; | |
| 3 | _ = @tagName(@intToEnum(E, 5)); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // tmp.zig:3:18: error: no tag by value 5 |
test/cases/compile_errors/stage1/test/type_mismatch_in_C_prototype_with_varargs.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | const fn_ty = ?fn ([*c]u8, ...) callconv(.C) void; | |
| 2 | extern fn fn_decl(fmt: [*:0]u8, ...) void; | |
| 3 | ||
| 4 | export fn main() void { | |
| 5 | const x: fn_ty = fn_decl; | |
| 6 | _ = x; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage1 | |
| 11 | // target=native | |
| 12 | // is_test=1 | |
| 13 | // | |
| 14 | // tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void' |
test/cases/compile_errors/stage1/truncate_undefined_value.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var z = @truncate(u8, @as(u16, undefined)); | |
| 3 | _ = z; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage1 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // tmp.zig:2:27: error: use of undefined value here causes undefined behavior |
test/cases/compile_errors/struct_field_missing_type.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const Letter = struct { | |
| 2 | A, | |
| 3 | }; | |
| 4 | export fn entry() void { | |
| 5 | var a = Letter { .A = {} }; | |
| 6 | _ = a; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :2:5: error: struct field missing type |
test/cases/compile_errors/struct_init_syntax_for_array.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const foo = [3]u16{ .x = 1024 }; | |
| 2 | comptime { | |
| 3 | _ = foo; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :1:13: error: initializing array with struct syntax |
test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(@typeInfo(struct { const foo = 1; })); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:9: error: reified structs must have no decls |
test/cases/compile_errors/struct_with_invalid_field.zig created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | const std = @import("std",); | |
| 2 | const Allocator = std.mem.Allocator; | |
| 3 | const ArrayList = std.ArrayList; | |
| 4 | ||
| 5 | const HeaderWeight = enum { | |
| 6 | H1, H2, H3, H4, H5, H6, | |
| 7 | }; | |
| 8 | ||
| 9 | const MdText = ArrayList(u8); | |
| 10 | ||
| 11 | const MdNode = union(enum) { | |
| 12 | Header: struct { | |
| 13 | text: MdText, | |
| 14 | weight: HeaderValue, | |
| 15 | }, | |
| 16 | }; | |
| 17 | ||
| 18 | export fn entry() void { | |
| 19 | const a = MdNode.Header { | |
| 20 | .text = MdText.init(std.testing.allocator), | |
| 21 | .weight = HeaderWeight.H1, | |
| 22 | }; | |
| 23 | _ = a; | |
| 24 | } | |
| 25 | ||
| 26 | // error | |
| 27 | // backend=stage2 | |
| 28 | // target=native | |
| 29 | // | |
| 30 | // :14:17: error: use of undeclared identifier 'HeaderValue' |
test/cases/compile_errors/suspend_inside_suspend_block.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = async foo(); | |
| 3 | } | |
| 4 | fn foo() void { | |
| 5 | suspend { | |
| 6 | suspend { | |
| 7 | } | |
| 8 | } | |
| 9 | } | |
| 10 | ||
| 11 | // error | |
| 12 | // backend=llvm | |
| 13 | // target=native | |
| 14 | // | |
| 15 | // :6:9: error: cannot suspend inside suspend block | |
| 16 | // :5:5: note: other suspend block here |
test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | const Number = enum { | |
| 2 | One, | |
| 3 | Two, | |
| 4 | Three, | |
| 5 | Four, | |
| 6 | }; | |
| 7 | fn f(n: Number) i32 { | |
| 8 | switch (n) { | |
| 9 | Number.One => 1, | |
| 10 | Number.Two => 2, | |
| 11 | Number.Three => @as(i32, 3), | |
| 12 | Number.Four => 4, | |
| 13 | Number.Two => 2, | |
| 14 | } | |
| 15 | } | |
| 16 | ||
| 17 | export fn entry() usize { return @sizeOf(@TypeOf(&f)); } | |
| 18 | ||
| 19 | // error | |
| 20 | // backend=stage2 | |
| 21 | // target=native | |
| 22 | // | |
| 23 | // :13:15: error: duplicate switch value | |
| 24 | // :10:15: note: previous value here |
test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | const Number = enum { | |
| 2 | One, | |
| 3 | Two, | |
| 4 | Three, | |
| 5 | Four, | |
| 6 | }; | |
| 7 | fn f(n: Number) i32 { | |
| 8 | switch (n) { | |
| 9 | Number.One => 1, | |
| 10 | Number.Two => 2, | |
| 11 | Number.Three => @as(i32, 3), | |
| 12 | Number.Four => 4, | |
| 13 | Number.Two => 2, | |
| 14 | else => 10, | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| 18 | export fn entry() usize { return @sizeOf(@TypeOf(&f)); } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=stage2 | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // :13:15: error: duplicate switch value | |
| 25 | // :10:15: note: previous value here |
test/cases/compile_errors/switch_expression-duplicate_type.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | fn foo(comptime T: type, x: T) u8 { | |
| 2 | _ = x; | |
| 3 | return switch (T) { | |
| 4 | u32 => 0, | |
| 5 | u64 => 1, | |
| 6 | u32 => 2, | |
| 7 | else => 3, | |
| 8 | }; | |
| 9 | } | |
| 10 | export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :6:9: error: duplicate switch value | |
| 17 | // :4:9: note: previous value here |
test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | const Test = struct { | |
| 2 | bar: i32, | |
| 3 | }; | |
| 4 | const Test2 = Test; | |
| 5 | fn foo(comptime T: type, x: T) u8 { | |
| 6 | _ = x; | |
| 7 | return switch (T) { | |
| 8 | Test => 0, | |
| 9 | u64 => 1, | |
| 10 | Test2 => 2, | |
| 11 | else => 3, | |
| 12 | }; | |
| 13 | } | |
| 14 | export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage2 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // :10:9: error: duplicate switch value | |
| 21 | // :8:9: note: previous value here |
test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | const Number = enum { | |
| 2 | One, | |
| 3 | Two, | |
| 4 | Three, | |
| 5 | Four, | |
| 6 | }; | |
| 7 | fn f(n: Number) i32 { | |
| 8 | switch (n) { | |
| 9 | Number.One => 1, | |
| 10 | Number.Two => 2, | |
| 11 | Number.Three => @as(i32, 3), | |
| 12 | } | |
| 13 | } | |
| 14 | ||
| 15 | export fn entry() usize { return @sizeOf(@TypeOf(&f)); } | |
| 16 | ||
| 17 | // error | |
| 18 | // backend=stage2 | |
| 19 | // target=native | |
| 20 | // | |
| 21 | // :8:5: error: switch must handle all possibilities | |
| 22 | // :8:5: note: unhandled enumeration value: 'Four' | |
| 23 | // :1:16: note: enum 'tmp.Number' declared here |
test/cases/compile_errors/switch_expression-multiple_else_prongs.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | fn f(x: u32) void { | |
| 2 | const value: bool = switch (x) { | |
| 3 | 1234 => false, | |
| 4 | else => true, | |
| 5 | else => true, | |
| 6 | }; | |
| 7 | } | |
| 8 | export fn entry() void { | |
| 9 | f(1234); | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :5:9: error: multiple else prongs in switch expression | |
| 17 | // :4:9: note: previous else prong here |
test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | fn foo(x: u8) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | } | |
| 5 | } | |
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :2:5: error: switch must handle all possibilities |
test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | const TestEnum = enum{ T1, T2 }; | |
| 2 | ||
| 3 | fn err(x: u8) TestEnum { | |
| 4 | switch (x) { | |
| 5 | 0 => return TestEnum.T1, | |
| 6 | else => return TestEnum.T2, | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | fn foo(x: u8) void { | |
| 11 | switch (err(x)) { | |
| 12 | TestEnum.T1 => {}, | |
| 13 | TestEnum.T2 => {}, | |
| 14 | else => {}, | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| 18 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 19 | ||
| 20 | // error | |
| 21 | // backend=llvm | |
| 22 | // target=native | |
| 23 | // | |
| 24 | // :14:14: error: unreachable else prong; all cases already handled |
test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | fn foo(x: i8) void { | |
| 2 | switch (x) { | |
| 3 | -128...0 => {}, | |
| 4 | 1 => {}, | |
| 5 | 2 => {}, | |
| 6 | 3 => {}, | |
| 7 | 4...127 => {}, | |
| 8 | else => {}, | |
| 9 | } | |
| 10 | } | |
| 11 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :8:14: error: unreachable else prong; all cases already handled |
test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | fn foo(x: u8) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | 1 => {}, | |
| 5 | 2 => {}, | |
| 6 | 3 => {}, | |
| 7 | 4...255 => {}, | |
| 8 | else => {}, | |
| 9 | } | |
| 10 | } | |
| 11 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 12 | ||
| 13 | // error | |
| 14 | // backend=stage2 | |
| 15 | // target=native | |
| 16 | // | |
| 17 | // :8:14: error: unreachable else prong; all cases already handled |
test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | fn foo(x: u1) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | 1 => {}, | |
| 5 | else => {}, | |
| 6 | } | |
| 7 | } | |
| 8 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 9 | ||
| 10 | // error | |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 13 | // | |
| 14 | // :5:14: error: unreachable else prong; all cases already handled |
test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | fn foo(x: u2) void { | |
| 2 | switch (x) { | |
| 3 | 0 => {}, | |
| 4 | 1 => {}, | |
| 5 | 2 => {}, | |
| 6 | 3 => {}, | |
| 7 | else => {}, | |
| 8 | } | |
| 9 | } | |
| 10 | export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :7:14: error: unreachable else prong; all cases already handled |
test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const Foo = enum { M }; | |
| 2 | ||
| 3 | export fn entry() void { | |
| 4 | var f = Foo.M; | |
| 5 | switch (f) {} | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :5:5: error: switch must handle all possibilities | |
| 13 | // :5:5: note: unhandled enumeration value: 'M' | |
| 14 | // :1:13: note: enum 'tmp.Foo' declared here |
test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | pub export fn entry1() void { | |
| 2 | var x: i32 = 0; | |
| 3 | switch (x) { | |
| 4 | 6...1 => {}, | |
| 5 | else => unreachable, | |
| 6 | } | |
| 7 | } | |
| 8 | pub export fn entr2() void { | |
| 9 | var x: i32 = 0; | |
| 10 | switch (x) { | |
| 11 | -1...-5 => {}, | |
| 12 | else => unreachable, | |
| 13 | } | |
| 14 | } | |
| 15 | ||
| 16 | // error | |
| 17 | // backend=stage2 | |
| 18 | // target=native | |
| 19 | // | |
| 20 | // :4:9: error: range start value is greater than the end value | |
| 21 | // :11:9: error: range start value is greater than the end value |
test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | const E = enum{ | |
| 2 | a, | |
| 3 | b, | |
| 4 | }; | |
| 5 | pub export fn entry() void { | |
| 6 | var e: E = .b; | |
| 7 | switch (e) { | |
| 8 | .a => {}, | |
| 9 | .b => {}, | |
| 10 | _ => {}, | |
| 11 | } | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // :7:5: error: '_' prong only allowed when switching on non-exhaustive enums | |
| 19 | // :10:11: note: '_' prong here |
test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | test "enum" { | |
| 2 | const E = enum(u8) {A, B, _}; | |
| 3 | _ = @tagName(@intToEnum(E, 5)); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // is_test=1 | |
| 10 | // | |
| 11 | // :3:9: error: no field with value '5' in enum 'test.enum.E' | |
| 12 | // :1:1: note: declared here |
test/cases/compile_errors/threadlocal_qualifier_on_const.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | threadlocal const x: i32 = 1234; | |
| 2 | export fn entry() i32 { | |
| 3 | return x; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :1:1: error: threadlocal variable cannot be constant |
test/cases/compile_errors/truncate_sign_mismatch.zig created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | export fn entry1() i8 { | |
| 2 | var x: u32 = 10; | |
| 3 | return @truncate(i8, x); | |
| 4 | } | |
| 5 | export fn entry2() u8 { | |
| 6 | var x: i32 = -10; | |
| 7 | return @truncate(u8, x); | |
| 8 | } | |
| 9 | export fn entry3() i8 { | |
| 10 | comptime var x: u32 = 10; | |
| 11 | return @truncate(i8, x); | |
| 12 | } | |
| 13 | export fn entry4() u8 { | |
| 14 | comptime var x: i32 = -10; | |
| 15 | return @truncate(u8, x); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=stage2 | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // :3:26: error: expected signed integer type, found 'u32' | |
| 23 | // :7:26: error: expected unsigned integer type, found 'i32' | |
| 24 | // :11:26: error: expected signed integer type, found 'u32' | |
| 25 | // :15:26: error: expected unsigned integer type, found 'i32' |
test/cases/compile_errors/try_in_function_with_non_error_return_type.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f() void { | |
| 2 | try something(); | |
| 3 | } | |
| 4 | fn something() anyerror!void { } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:5: error: expected type 'void', found 'anyerror' |
test/cases/compile_errors/type_mismatch_in_C_prototype_with_varargs.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const fn_ty = ?fn ([*c]u8, ...) callconv(.C) void; | |
| 2 | extern fn fn_decl(fmt: [*:0]u8, ...) void; | |
| 3 | ||
| 4 | export fn main() void { | |
| 5 | const x: fn_ty = fn_decl; | |
| 6 | _ = x; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void' |
test/cases/compile_errors/undeclared_identifier.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn a() void { | |
| 2 | return | |
| 3 | b + | |
| 4 | c; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/undeclared_identifier_error_should_mark_fn_as_impure.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | export fn foo() void { | |
| 2 | test_a_thing(); | |
| 3 | } | |
| 4 | fn test_a_thing() void { | |
| 5 | bad_fn_call(); | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :5:5: error: use of undeclared identifier 'bad_fn_call' |
test/cases/compile_errors/undeclared_identifier_in_unanalyzed_branch.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn a() void { | |
| 2 | if (false) { | |
| 3 | lol_this_doesnt_exist = nonsense; | |
| 4 | } | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:9: error: use of undeclared identifier 'lol_this_doesnt_exist' |
test/cases/compile_errors/undefined_as_field_type_is_rejected.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a() void { | |
| 2 | b(); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/undefined_function_call.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn a() void { | |
| 2 | b(); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/underscore_is_not_a_declarable_symbol.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f1() usize { | |
| 2 | var _: usize = 2; | |
| 3 | return _; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:9: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/underscore_should_not_be_usable_inside_for.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn returns() void { | |
| 2 | for ([_]void{}) |_, i| { | |
| 3 | for ([_]void{}) |_, j| { | |
| 4 | return _; | |
| 5 | } | |
| 6 | } | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 12 | // | |
| 13 | // :4:20: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/underscore_should_not_be_usable_inside_while.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | export fn returns() void { | |
| 2 | while (optionalReturn()) |_| { | |
| 3 | while (optionalReturn()) |_| { | |
| 4 | return _; | |
| 5 | } | |
| 6 | } | |
| 7 | } | |
| 8 | fn optionalReturn() ?u32 { | |
| 9 | return 1; | |
| 10 | } | |
| 11 | ||
| 12 | // error | |
| 13 | // backend=stage2 | |
| 14 | // target=native | |
| 15 | // | |
| 16 | // :4:20: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/underscore_should_not_be_usable_inside_while_else.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | export fn returns() void { | |
| 2 | while (optionalReturnError()) |_| { | |
| 3 | while (optionalReturnError()) |_| { | |
| 4 | return; | |
| 5 | } else |_| { | |
| 6 | if (_ == error.optionalReturnError) return; | |
| 7 | } | |
| 8 | } | |
| 9 | } | |
| 10 | fn optionalReturnError() !?u32 { | |
| 11 | return error.optionalReturnError; | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // :6:17: error: '_' used as an identifier without @"_" syntax |
test/cases/compile_errors/union_fields_with_value_assignments.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | const Foo = union {}; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:13: error: union declarations must have at least one tag |
test/cases/compile_errors/union_with_0_fields.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | const Foo = union {}; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:13: error: union declarations must have at least one tag |
test/cases/compile_errors/union_with_specified_enum_omits_field.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | const Letter = enum { | |
| 2 | A, | |
| 3 | B, | |
| 4 | C, | |
| 5 | }; | |
| 6 | const Payload = union(Letter) { | |
| 7 | A: i32, | |
| 8 | B: f64, | |
| 9 | }; | |
| 10 | export fn entry() usize { | |
| 11 | return @sizeOf(Payload); | |
| 12 | } | |
| 13 | ||
| 14 | // error | |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 17 | // | |
| 18 | // :6:1: error: enum field(s) missing in union | |
| 19 | // :4:5: note: field 'C' missing, declared here | |
| 20 | // :1:16: note: enum declared here |
test/cases/compile_errors/unreachable_code-double_break.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn a() void { | |
| 2 | const b = blk: { | |
| 3 | break :blk break :blk @as(u32, 1); | |
| 4 | }; | |
| 5 | _ = b; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :3:9: error: unreachable code | |
| 13 | // :3:20: note: control flow is diverted here |
test/cases/compile_errors/unreachable_code-nested_returns.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn a() i32 { | |
| 2 | return return 1; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: unreachable code | |
| 10 | // :2:12: note: control flow is diverted here |
test/cases/compile_errors/unreachable_code.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | export fn a() void { | |
| 2 | return; | |
| 3 | b(); | |
| 4 | } | |
| 5 | ||
| 6 | fn b() void {} | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :3:6: error: unreachable code | |
| 13 | // :2:5: note: control flow is diverted here |
test/cases/compile_errors/unreachable_variable.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f() void { | |
| 2 | const a: noreturn = {}; | |
| 3 | _ = a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:25: error: expected type 'noreturn', found 'void' |
test/cases/compile_errors/unreachable_with_return.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | fn a() noreturn {return;} | |
| 2 | export fn entry() void { a(); } | |
| 3 | ||
| 4 | // error | |
| 5 | // backend=stage2 | |
| 6 | // target=native | |
| 7 | // | |
| 8 | // :1:18: error: expected type 'noreturn', found 'void' |
test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | var v = 25; | |
| 2 | export fn entry() void { | |
| 3 | var arr: [v]u8 = undefined; | |
| 4 | _ = arr; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :1:1: error: variable of type 'comptime_int' must be const or comptime |
test/cases/compile_errors/use_of_undeclared_identifier.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn f() void { | |
| 2 | b = 3; | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:5: error: use of undeclared identifier 'b' |
test/cases/compile_errors/using_invalid_types_in_function_call_raises_an_error.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const MenuEffect = enum {}; | |
| 2 | fn func(effect: MenuEffect) void { _ = effect; } | |
| 3 | export fn entry() void { | |
| 4 | func(MenuEffect.ThisDoesNotExist); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :1:20: error: enum declarations must have at least one tag |
test/cases/compile_errors/usingnamespace_with_wrong_type.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | usingnamespace void; | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage2 | |
| 5 | // target=native | |
| 6 | // | |
| 7 | // :1:1: error: type void has no namespace |
test/cases/compile_errors/variable_has_wrong_type.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn f() i32 { | |
| 2 | const a = "a"; | |
| 3 | return a; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:12: error: expected type 'i32', found '*const [1:0]u8' |
test/cases/compile_errors/variable_initialization_compile_error_then_referenced.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | fn Undeclared() type { | |
| 2 | return T; | |
| 3 | } | |
| 4 | fn Gen() type { | |
| 5 | const X = Undeclared(); | |
| 6 | return struct { | |
| 7 | x: X, | |
| 8 | }; | |
| 9 | } | |
| 10 | export fn entry() void { | |
| 11 | const S = Gen(); | |
| 12 | _ = S; | |
| 13 | } | |
| 14 | ||
| 15 | // error | |
| 16 | // backend=stage2 | |
| 17 | // target=native | |
| 18 | // | |
| 19 | // :2:12: error: use of undeclared identifier 'T' |
test/cases/compile_errors/variable_with_type_noreturn.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry9() void { | |
| 2 | var z: noreturn = return; | |
| 3 | _ = z; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:5: error: unreachable code | |
| 11 | // :2:23: note: control flow is diverted here |
test/cases/compile_errors/volatile_on_global_assembly.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | comptime { | |
| 2 | asm volatile (""); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:9: error: volatile is meaningless on global assembly |
test/cases/compile_errors/while_expected_bool_got_error_union.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn foo() void { | |
| 2 | while (bar()) {} | |
| 3 | } | |
| 4 | fn bar() anyerror!i32 { return 1; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:15: error: expected type 'bool', found 'anyerror!i32' |
test/cases/compile_errors/while_expected_bool_got_optional.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn foo() void { | |
| 2 | while (bar()) {} | |
| 3 | } | |
| 4 | fn bar() ?i32 { return 1; } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:15: error: expected type 'bool', found '?i32' |
test/cases/compile_errors/write_to_const_global_variable.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const x : i32 = 99; | |
| 2 | fn f() void { | |
| 3 | x = 1; | |
| 4 | } | |
| 5 | export fn entry() void { f(); } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :3:9: error: cannot assign to constant |
test/cases/compile_errors/wrong_size_to_an_array_literal.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | const array = [2]u8{1, 2, 3}; | |
| 3 | _ = array; | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :2:31: error: index 2 outside array of length 2 |
test/cases/compile_errors/wrong_type_passed_to_panic.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | export fn entry() void { | |
| 2 | var e = error.Foo; | |
| 3 | @panic(e); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 9 | // | |
| 10 | // :3:12: error: expected type '[]const u8', found 'error{Foo}' |
test/cases/compile_errors/wrong_type_to_hasField.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | export fn entry() bool { | |
| 2 | return @hasField(i32, "hi"); | |
| 3 | } | |
| 4 | ||
| 5 | // error | |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 8 | // | |
| 9 | // :2:22: error: type 'i32' does not support '@hasField' |
test/cases/compile_log.0.zig+1-1| ... | ... | @@ -14,4 +14,4 @@ fn x() void {} |
| 14 | 14 | |
| 15 | 15 | // error |
| 16 | 16 | // |
| 17 | // :6:23: error: expected usize, found bool | |
| 17 | // :6:23: error: expected type 'usize', found 'bool' |
test/cases/llvm/any_typed_null_to_any_typed_optional.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: ?*anyopaque = undefined; | |
| 3 | a = @as(?usize, null); | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // output_mode=Exe | |
| 8 | // backend=stage2,llvm | |
| 9 | // target=x86_64-linux,x86_64-macos | |
| 10 | // | |
| 11 | // :3:21: error: expected *anyopaque, found ?usize |
test/cases/llvm/invalid_address_space_coercion.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | fn entry(a: *addrspace(.gs) i32) *i32 { | |
| 2 | return a; | |
| 3 | } | |
| 4 | pub fn main() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Exe | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:12: error: expected *i32, found *addrspace(.gs) i32 |
test/cases/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | fn entry(a: *addrspace(.gs) i32) *i32 { | |
| 2 | return &a.*; | |
| 3 | } | |
| 4 | pub fn main() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Exe | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:12: error: expected *i32, found *addrspace(.gs) i32 |
test/cases/llvm/pointer_with_different_address_spaces.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | fn entry(a: *addrspace(.gs) i32) *addrspace(.fs) i32 { | |
| 2 | return a; | |
| 3 | } | |
| 4 | export fn entry2() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Obj | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:12: error: expected *addrspace(.fs) i32, found *addrspace(.gs) i32 |
test/cases/llvm/pointers_with_different_address_spaces.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | fn entry(a: ?*addrspace(.gs) i32) *i32 { | |
| 2 | return a.?; | |
| 3 | } | |
| 4 | pub fn main() void { | |
| 5 | _ = entry; | |
| 6 | } | |
| 7 | ||
| 8 | // error | |
| 9 | // output_mode=Exe | |
| 10 | // backend=stage2,llvm | |
| 11 | // target=x86_64-linux,x86_64-macos | |
| 12 | // | |
| 13 | // :2:13: error: expected *i32, found *addrspace(.gs) i32 |
test/cases/x86_64-linux/hello_world_with_updates.1.zig+1-1| ... | ... | @@ -2,4 +2,4 @@ pub export fn _start() noreturn {} |
| 2 | 2 | |
| 3 | 3 | // error |
| 4 | 4 | // |
| 5 | // :1:34: error: expected noreturn, found void | |
| 5 | // :1:34: error: expected type 'noreturn', found 'void' |
test/cases/x86_64-linux/inline_assembly.0.zig+1-1| ... | ... | @@ -13,4 +13,4 @@ pub fn main() void { |
| 13 | 13 | // output_mode=Exe |
| 14 | 14 | // target=x86_64-linux |
| 15 | 15 | // |
| 16 | // :4:27: error: expected type, found comptime_int | |
| 16 | // :4:27: error: expected type 'type', found 'comptime_int' |
test/cases/x86_64-macos/hello_world_with_updates.1.zig+1-1| ... | ... | @@ -2,4 +2,4 @@ pub export fn main() noreturn {} |
| 2 | 2 | |
| 3 | 3 | // error |
| 4 | 4 | // |
| 5 | // :1:32: error: expected noreturn, found void | |
| 5 | // :1:32: error: expected type 'noreturn', found 'void' |
test/stage2/cbe.zig+5-5| ... | ... | @@ -96,13 +96,13 @@ pub fn addCases(ctx: *TestContext) !void { |
| 96 | 96 | \\ _ = @intToError(0); |
| 97 | 97 | \\ return 0; |
| 98 | 98 | \\} |
| 99 | , &.{":2:21: error: integer value 0 represents no error"}); | |
| 99 | , &.{":2:21: error: integer value '0' represents no error"}); | |
| 100 | 100 | case.addError( |
| 101 | 101 | \\pub export fn main() c_int { |
| 102 | 102 | \\ _ = @intToError(3); |
| 103 | 103 | \\ return 0; |
| 104 | 104 | \\} |
| 105 | , &.{":2:21: error: integer value 3 represents no error"}); | |
| 105 | , &.{":2:21: error: integer value '3' represents no error"}); | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | { |
| ... | ... | @@ -739,7 +739,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 739 | 739 | \\ _ = @enumToInt(a); |
| 740 | 740 | \\} |
| 741 | 741 | , &.{ |
| 742 | ":3:20: error: expected enum or tagged union, found bool", | |
| 742 | ":3:20: error: expected enum or tagged union, found 'bool'", | |
| 743 | 743 | }); |
| 744 | 744 | |
| 745 | 745 | case.addError( |
| ... | ... | @@ -748,7 +748,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 748 | 748 | \\ _ = @intToEnum(bool, a); |
| 749 | 749 | \\} |
| 750 | 750 | , &.{ |
| 751 | ":3:20: error: expected enum, found bool", | |
| 751 | ":3:20: error: expected enum, found 'bool'", | |
| 752 | 752 | }); |
| 753 | 753 | |
| 754 | 754 | case.addError( |
| ... | ... | @@ -757,7 +757,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 757 | 757 | \\ _ = @intToEnum(E, 3); |
| 758 | 758 | \\} |
| 759 | 759 | , &.{ |
| 760 | ":3:9: error: enum 'tmp.E' has no tag with value 3", | |
| 760 | ":3:9: error: enum 'tmp.E' has no tag with value '3'", | |
| 761 | 761 | ":1:11: note: enum declared here", |
| 762 | 762 | }); |
| 763 | 763 |