move passing stage1 compile error tests to stage2

This commit is contained in:
Veikka Tuominen 2022-06-27 18:32:59 +03:00 committed by Jakub Konka
parent c248af3bdc
commit 3204d00a5e
421 changed files with 1686 additions and 1636 deletions

View File

@ -4464,6 +4464,7 @@ fn containerDecl(
var total_fields: usize = 0;
var decls: usize = 0;
var nonexhaustive_node: Ast.Node.Index = 0;
var nonfinal_nonexhaustive = false;
for (container_decl.ast.members) |member_node| {
const member = switch (node_tags[member_node]) {
.container_field_init => tree.containerFieldInit(member_node),
@ -4515,6 +4516,8 @@ fn containerDecl(
return astgen.failNode(member.ast.value_expr, "'_' is used to mark an enum as non-exhaustive and cannot be assigned a value", .{});
}
continue;
} else if (nonexhaustive_node != 0) {
nonfinal_nonexhaustive = true;
}
total_fields += 1;
if (member.ast.value_expr != 0) {
@ -4524,6 +4527,9 @@ fn containerDecl(
values += 1;
}
}
if (nonfinal_nonexhaustive) {
return astgen.failNode(nonexhaustive_node, "'_' field of non-exhaustive enum must be last", .{});
}
break :blk .{
.total_fields = total_fields,
.values = values,

View File

@ -1707,7 +1707,7 @@ fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: T
}
fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, optional_ty: Type) CompileError {
return sema.fail(block, src, "expected optional type, found {}", .{optional_ty.fmt(sema.mod)});
return sema.fail(block, src, "expected optional type, found '{}'", .{optional_ty.fmt(sema.mod)});
}
fn failWithArrayInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError {
@ -1844,7 +1844,7 @@ pub fn resolveAlign(
const alignment = @intCast(u32, alignment_big); // We coerce to u16 in the prev line.
if (alignment == 0) return sema.fail(block, src, "alignment must be >= 1", .{});
if (!std.math.isPowerOfTwo(alignment)) {
return sema.fail(block, src, "alignment value {d} is not a power of two", .{
return sema.fail(block, src, "alignment value '{d}' is not a power of two", .{
alignment,
});
}
@ -2376,6 +2376,12 @@ fn zirEnumDecl(
}
}
if (small.nonexhaustive) {
if (fields_len > 1 and std.math.log2_int(u64, fields_len) == enum_obj.tag_ty.bitSize(sema.mod.getTarget())) {
return sema.fail(block, src, "non-exhaustive enum specifies every value", .{});
}
}
try enum_obj.fields.ensureTotalCapacity(new_decl_arena_allocator, fields_len);
const any_values = for (sema.code.extra[body_end..][0..bit_bags_count]) |bag| {
if (bag != 0) break true;
@ -4540,6 +4546,7 @@ fn analyzeBlockBody(
// to emit a jump instruction to after the block when it encounters the break.
try parent_block.instructions.append(gpa, merges.block_inst);
const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items, .none);
// TODO add note "missing else causes void value"
const type_src = src; // TODO: better source location
const valid_rt = try sema.validateRunTimeType(child_block, type_src, resolved_ty, false);
@ -4761,7 +4768,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
const msg = msg: {
const msg = try sema.errMsg(block, src, "multiple @setAlignStack in the same function body", .{});
errdefer msg.destroy(sema.gpa);
try sema.errNote(block, src, msg, "other instance here", .{});
try sema.errNote(block, gop.value_ptr.src, msg, "other instance here", .{});
break :msg msg;
};
return sema.failWithOwnedErrorMsg(block, msg);
@ -6155,7 +6162,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
const payload = try sema.resolveType(block, rhs_src, extra.rhs);
if (error_set.zigTypeTag() != .ErrorSet) {
return sema.fail(block, lhs_src, "expected error set type, found {}", .{
return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{
error_set.fmt(sema.mod),
});
}
@ -6243,7 +6250,7 @@ fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
if (try sema.resolveDefinedValue(block, operand_src, operand)) |value| {
const int = try sema.usizeCast(block, operand_src, value.toUnsignedInt(target));
if (int > sema.mod.global_error_set.count() or int == 0)
return sema.fail(block, operand_src, "integer value {d} represents no error", .{int});
return sema.fail(block, operand_src, "integer value '{d}' represents no error", .{int});
const payload = try sema.arena.create(Value.Payload.Error);
payload.* = .{
.base = .{ .tag = .@"error" },
@ -6288,9 +6295,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs);
const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs);
if (lhs_ty.zigTypeTag() != .ErrorSet)
return sema.fail(block, lhs_src, "expected error set type, found {}", .{lhs_ty.fmt(sema.mod)});
return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{lhs_ty.fmt(sema.mod)});
if (rhs_ty.zigTypeTag() != .ErrorSet)
return sema.fail(block, rhs_src, "expected error set type, found {}", .{rhs_ty.fmt(sema.mod)});
return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(sema.mod)});
// Anything merged with anyerror is anyerror.
if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) {
@ -6351,7 +6358,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
break :blk try sema.unionToTag(block, tag_ty, operand, operand_src);
},
else => {
return sema.fail(block, operand_src, "expected enum or tagged union, found {}", .{
return sema.fail(block, operand_src, "expected enum or tagged union, found '{}'", .{
operand_ty.fmt(sema.mod),
});
},
@ -6385,7 +6392,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
const operand = try sema.resolveInst(extra.rhs);
if (dest_ty.zigTypeTag() != .Enum) {
return sema.fail(block, dest_ty_src, "expected enum, found {}", .{dest_ty.fmt(sema.mod)});
return sema.fail(block, dest_ty_src, "expected enum, found '{}'", .{dest_ty.fmt(sema.mod)});
}
if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |int_val| {
@ -6400,7 +6407,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
const msg = try sema.errMsg(
block,
src,
"enum '{}' has no tag with value {}",
"enum '{}' has no tag with value '{}'",
.{ dest_ty.fmt(sema.mod), int_val.fmtValue(sema.typeOf(operand), sema.mod) },
);
errdefer msg.destroy(sema.gpa);
@ -6452,7 +6459,7 @@ fn analyzeOptionalPayloadPtr(
const opt_type = optional_ptr_ty.elemType();
if (opt_type.zigTypeTag() != .Optional) {
return sema.fail(block, src, "expected optional type, found {}", .{opt_type.fmt(sema.mod)});
return sema.fail(block, src, "expected optional type, found '{}'", .{opt_type.fmt(sema.mod)});
}
const child_type = try opt_type.optionalChildAlloc(sema.arena);
@ -6640,7 +6647,7 @@ fn analyzeErrUnionPayloadPtr(
assert(operand_ty.zigTypeTag() == .Pointer);
if (operand_ty.elemType().zigTypeTag() != .ErrorUnion) {
return sema.fail(block, src, "expected error union type, found {}", .{
return sema.fail(block, src, "expected error union type, found '{}'", .{
operand_ty.elemType().fmt(sema.mod),
});
}
@ -6739,7 +6746,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
assert(operand_ty.zigTypeTag() == .Pointer);
if (operand_ty.elemType().zigTypeTag() != .ErrorUnion) {
return sema.fail(block, src, "expected error union type, found {}", .{
return sema.fail(block, src, "expected error union type, found '{}'", .{
operand_ty.elemType().fmt(sema.mod),
});
}
@ -7639,7 +7646,6 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
defer tracy.end();
const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
const src = inst_data.src();
const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
@ -7674,7 +7680,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
return sema.addConstant(dest_ty, try operand_val.floatCast(sema.arena, dest_ty, target));
}
if (dest_is_comptime_float) {
return sema.fail(block, src, "unable to cast runtime value to 'comptime_float'", .{});
return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_float'", .{});
}
const src_bits = operand_ty.floatBits(target);
const dst_bits = dest_ty.floatBits(target);
@ -11664,8 +11670,8 @@ fn analyzeCmp(
const instructions = &[_]Air.Inst.Ref{ lhs, rhs };
const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ .override = &[_]LazySrcLoc{ lhs_src, rhs_src } });
if (!resolved_type.isSelfComparable(is_equality_cmp)) {
return sema.fail(block, src, "{s} operator not allowed for type '{}'", .{
@tagName(op), resolved_type.fmt(sema.mod),
return sema.fail(block, src, "operator {s} not allowed for type '{}'", .{
compareOperatorName(op), resolved_type.fmt(sema.mod),
});
}
const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
@ -11673,6 +11679,17 @@ fn analyzeCmp(
return sema.cmpSelf(block, casted_lhs, casted_rhs, op, lhs_src, rhs_src);
}
fn compareOperatorName(comp: std.math.CompareOperator) []const u8 {
return switch (comp) {
.lt => "<",
.lte => "<=",
.eq => "==",
.gte => ">=",
.gt => ">",
.neq => "!=",
};
}
fn cmpSelf(
sema: *Sema,
block: *Block,
@ -14382,7 +14399,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
};
return sema.failWithOwnedErrorMsg(block, msg);
},
else => return sema.fail(block, operand_src, "expected enum or union; found {}", .{
else => return sema.fail(block, operand_src, "expected enum or union; found '{}'", .{
operand_ty.fmt(mod),
}),
};
@ -14392,8 +14409,8 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
const field_index = enum_ty.enumTagFieldIndex(val, mod) orelse {
const enum_decl = mod.declPtr(enum_decl_index);
const msg = msg: {
const msg = try sema.errMsg(block, src, "no field with value {} in enum '{s}'", .{
casted_operand, enum_decl.name,
const msg = try sema.errMsg(block, src, "no field with value '{}' in enum '{s}'", .{
val.fmtValue(enum_ty, sema.mod), enum_decl.name,
});
errdefer msg.destroy(sema.gpa);
try mod.errNoteNonLazy(enum_decl.srcLoc(), msg, "declared here", .{});
@ -14458,6 +14475,8 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
var buffer: Value.ToTypeBuffer = undefined;
const child_ty = child_val.toType(&buffer);
try sema.checkVectorElemType(block, src, child_ty);
const ty = try Type.vector(sema.arena, len, try child_ty.copy(sema.arena));
return sema.addType(ty);
},
@ -15099,6 +15118,8 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
const result_val = try sema.floatToInt(block, operand_src, val, operand_ty, dest_ty);
return sema.addConstant(dest_ty, result_val);
} else if (dest_ty.zigTypeTag() == .ComptimeInt) {
return sema.failWithNeededComptime(block, operand_src);
}
try sema.requireRuntimeBlock(block, operand_src);
@ -15121,6 +15142,8 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
const target = sema.mod.getTarget();
const result_val = try val.intToFloat(sema.arena, operand_ty, dest_ty, target);
return sema.addConstant(dest_ty, result_val);
} else if (dest_ty.zigTypeTag() == .ComptimeFloat) {
return sema.failWithNeededComptime(block, operand_src);
}
try sema.requireRuntimeBlock(block, operand_src);
@ -15242,7 +15265,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
const msg = try sema.errMsg(
block,
src,
"error.{s} not a member of error set '{}'",
"'error.{s}' not a member of error set '{}'",
.{ error_name, dest_ty.fmt(sema.mod) },
);
errdefer msg.destroy(sema.gpa);
@ -15633,22 +15656,29 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6
try sema.resolveTypeLayout(block, lhs_src, ty);
if (ty.tag() != .@"struct") {
return sema.fail(
block,
lhs_src,
"expected struct type, found '{}'",
.{ty.fmt(sema.mod)},
);
const msg = msg: {
const msg = try sema.errMsg(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(sema.mod)});
errdefer msg.destroy(sema.gpa);
try sema.addDeclaredHereNote(msg, ty);
break :msg msg;
};
return sema.failWithOwnedErrorMsg(block, msg);
}
const fields = ty.structFields();
const index = fields.getIndex(field_name) orelse {
return sema.fail(
block,
rhs_src,
"struct '{}' has no field '{s}'",
.{ ty.fmt(sema.mod), field_name },
);
const msg = msg: {
const msg = try sema.errMsg(
block,
rhs_src,
"struct '{}' has no field '{s}'",
.{ ty.fmt(sema.mod), field_name },
);
errdefer msg.destroy(sema.gpa);
try sema.addDeclaredHereNote(msg, ty);
break :msg msg;
};
return sema.failWithOwnedErrorMsg(block, msg);
};
switch (ty.containerLayout()) {
@ -15701,7 +15731,7 @@ fn checkPtrOperand(
const msg = try sema.errMsg(
block,
ty_src,
"expected pointer, found {}",
"expected pointer, found '{}'",
.{ty.fmt(sema.mod)},
);
errdefer msg.destroy(sema.gpa);
@ -15817,7 +15847,7 @@ fn checkAtomicPtrOperand(
error.BadType => return sema.fail(
block,
elem_ty_src,
"expected bool, integer, float, enum, or pointer type; found {}",
"expected bool, integer, float, enum, or pointer type; found '{}'",
.{elem_ty.fmt(sema.mod)},
),
};
@ -16026,7 +16056,7 @@ fn checkVectorizableBinaryOperands(
}
} else {
const msg = msg: {
const msg = try sema.errMsg(block, src, "mixed scalar and vector operands: {} and {}", .{
const msg = try sema.errMsg(block, src, "mixed scalar and vector operands: '{}' and '{}'", .{
lhs_ty.fmt(sema.mod), rhs_ty.fmt(sema.mod),
});
errdefer msg.destroy(sema.gpa);
@ -16069,6 +16099,10 @@ fn resolveExportOptions(
const visibility_val = try sema.resolveConstValue(block, src, visibility_operand);
const visibility = visibility_val.toEnum(std.builtin.SymbolVisibility);
if (name.len < 1) {
return sema.fail(block, src, "exported symbol name cannot be empty", .{});
}
if (visibility != .default and linkage == .Internal) {
return sema.fail(block, src, "symbol '{s}' exported with internal linkage has non-default visibility {s}", .{
name, @tagName(visibility),
@ -16247,7 +16281,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
const target = sema.mod.getTarget();
if (operand_ty.zigTypeTag() != .Vector) {
return sema.fail(block, operand_src, "expected vector, found {}", .{operand_ty.fmt(sema.mod)});
return sema.fail(block, operand_src, "expected vector, found '{}'", .{operand_ty.fmt(sema.mod)});
}
const scalar_ty = operand_ty.childType();
@ -16256,13 +16290,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
switch (operation) {
.And, .Or, .Xor => switch (scalar_ty.zigTypeTag()) {
.Int, .Bool => {},
else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found {}", .{
else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{}'", .{
@tagName(operation), operand_ty.fmt(sema.mod),
}),
},
.Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag()) {
.Int, .Float => {},
else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found {}", .{
else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{}'", .{
@tagName(operation), operand_ty.fmt(sema.mod),
}),
},
@ -16321,7 +16355,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
const mask_len = switch (sema.typeOf(mask).zigTypeTag()) {
.Array, .Vector => sema.typeOf(mask).arrayLen(),
else => return sema.fail(block, mask_src, "expected vector or array, found {}", .{sema.typeOf(mask).fmt(sema.mod)}),
else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(sema.mod)}),
};
mask_ty = try Type.Tag.vector.create(sema.arena, .{
.len = mask_len,
@ -16356,7 +16390,7 @@ fn analyzeShuffle(
var maybe_a_len = switch (sema.typeOf(a).zigTypeTag()) {
.Array, .Vector => sema.typeOf(a).arrayLen(),
.Undefined => null,
else => return sema.fail(block, a_src, "expected vector or array with element type {}, found {}", .{
else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{
elem_ty.fmt(sema.mod),
sema.typeOf(a).fmt(sema.mod),
}),
@ -16364,7 +16398,7 @@ fn analyzeShuffle(
var maybe_b_len = switch (sema.typeOf(b).zigTypeTag()) {
.Array, .Vector => sema.typeOf(b).arrayLen(),
.Undefined => null,
else => return sema.fail(block, b_src, "expected vector or array with element type {}, found {}", .{
else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{
elem_ty.fmt(sema.mod),
sema.typeOf(b).fmt(sema.mod),
}),
@ -16412,7 +16446,7 @@ fn analyzeShuffle(
const msg = try sema.errMsg(block, mask_src, "mask index {d} has out-of-bounds selection", .{i});
errdefer msg.destroy(sema.gpa);
try sema.errNote(block, operand_info[chosen][1], msg, "selected index {d} out of bounds of {}", .{
try sema.errNote(block, operand_info[chosen][1], msg, "selected index {d} out of bounds of '{}'", .{
unsigned,
operand_info[chosen][2].fmt(sema.mod),
});
@ -16881,7 +16915,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
const args_ty = sema.typeOf(args);
if (!args_ty.isTuple() and args_ty.tag() != .empty_struct_literal) {
return sema.fail(block, args_src, "expected a tuple, found {}", .{args_ty.fmt(sema.mod)});
return sema.fail(block, args_src, "expected a tuple, found '{}'", .{args_ty.fmt(sema.mod)});
}
var resolved_args: []Air.Inst.Ref = undefined;
@ -18217,9 +18251,15 @@ fn fieldVal(
if (payload.data.names.getEntry(field_name)) |entry| {
break :blk entry.key_ptr.*;
}
return sema.fail(block, src, "no error named '{s}' in '{}'", .{
field_name, child_type.fmt(sema.mod),
});
const msg = msg: {
const msg = try sema.errMsg(block, src, "no error named '{s}' in '{}'", .{
field_name, child_type.fmt(sema.mod),
});
errdefer msg.destroy(sema.gpa);
try sema.addDeclaredHereNote(msg, child_type);
break :msg msg;
};
return sema.failWithOwnedErrorMsg(block, msg);
} else (try sema.mod.getErrorValue(field_name)).key;
return sema.addConstant(
@ -18894,12 +18934,12 @@ fn tupleFieldIndex(
field_name_src: LazySrcLoc,
) CompileError!u32 {
const field_index = std.fmt.parseUnsigned(u32, field_name, 10) catch |err| {
return sema.fail(block, field_name_src, "tuple {} has no such field '{s}': {s}", .{
return sema.fail(block, field_name_src, "tuple '{}' has no such field '{s}': {s}", .{
tuple_ty.fmt(sema.mod), field_name, @errorName(err),
});
};
if (field_index >= tuple_ty.structFieldCount()) {
return sema.fail(block, field_name_src, "tuple {} has no such field '{s}'", .{
return sema.fail(block, field_name_src, "tuple '{}' has no such field '{s}'", .{
tuple_ty.fmt(sema.mod), field_name,
});
}
@ -19809,7 +19849,7 @@ fn coerce(
return sema.fail(
block,
inst_src,
"fractional component prevents float value {} from coercion to type '{}'",
"fractional component prevents float value '{}' from coercion to type '{}'",
.{ val.fmtValue(inst_ty, sema.mod), dest_ty.fmt(sema.mod) },
);
}
@ -19820,7 +19860,7 @@ fn coerce(
if (try sema.resolveDefinedValue(block, inst_src, inst)) |val| {
// comptime known integer to other number
if (!(try sema.intFitsInType(block, inst_src, val, dest_ty))) {
return sema.fail(block, inst_src, "type {} cannot represent integer value {}", .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) });
return sema.fail(block, inst_src, "type '{}' cannot represent integer value '{}'", .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) });
}
return try sema.addConstant(dest_ty, val);
}
@ -19854,7 +19894,7 @@ fn coerce(
return sema.fail(
block,
inst_src,
"type {} cannot represent float value {}",
"type '{}' cannot represent float value '{}'",
.{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) },
);
}
@ -19878,7 +19918,7 @@ fn coerce(
// return sema.fail(
// block,
// inst_src,
// "type {} cannot represent integer value {}",
// "type '{}' cannot represent integer value '{}'",
// .{ dest_ty.fmt(sema.mod), val },
// );
//}
@ -20021,7 +20061,7 @@ fn coerce(
return sema.addConstUndef(dest_ty);
}
return sema.fail(block, inst_src, "expected {}, found {}", .{ dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod) });
return sema.fail(block, inst_src, "expected type '{}', found '{}'", .{ dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod) });
}
const InMemoryCoercionResult = enum {
@ -21541,7 +21581,7 @@ fn coerceEnumToUnion(
const tag_ty = union_ty.unionTagType() orelse {
const msg = msg: {
const msg = try sema.errMsg(block, inst_src, "expected {}, found {}", .{
const msg = try sema.errMsg(block, inst_src, "expected type '{}', found '{}'", .{
union_ty.fmt(sema.mod), inst_ty.fmt(sema.mod),
});
errdefer msg.destroy(sema.gpa);
@ -21557,7 +21597,7 @@ fn coerceEnumToUnion(
const union_obj = union_ty.cast(Type.Payload.Union).?.data;
const field_index = union_obj.tag_ty.enumTagFieldIndex(val, sema.mod) orelse {
const msg = msg: {
const msg = try sema.errMsg(block, inst_src, "union {} has no tag with value {}", .{
const msg = try sema.errMsg(block, inst_src, "union '{}' has no tag with value '{}'", .{
union_ty.fmt(sema.mod), val.fmtValue(tag_ty, sema.mod),
});
errdefer msg.destroy(sema.gpa);
@ -21593,7 +21633,7 @@ fn coerceEnumToUnion(
if (tag_ty.isNonexhaustiveEnum()) {
const msg = msg: {
const msg = try sema.errMsg(block, inst_src, "runtime coercion to union {} from non-exhaustive enum", .{
const msg = try sema.errMsg(block, inst_src, "runtime coercion to union '{}' from non-exhaustive enum", .{
union_ty.fmt(sema.mod),
});
errdefer msg.destroy(sema.gpa);
@ -21710,7 +21750,7 @@ fn coerceArrayLike(
if (dest_len != inst_len) {
const msg = msg: {
const msg = try sema.errMsg(block, inst_src, "expected {}, found {}", .{
const msg = try sema.errMsg(block, inst_src, "expected type '{}', found '{}'", .{
dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod),
});
errdefer msg.destroy(sema.gpa);
@ -21781,7 +21821,7 @@ fn coerceTupleToArray(
if (dest_len != inst_len) {
const msg = msg: {
const msg = try sema.errMsg(block, inst_src, "expected {}, found {}", .{
const msg = try sema.errMsg(block, inst_src, "expected type '{}', found '{}'", .{
dest_ty.fmt(sema.mod), inst_ty.fmt(sema.mod),
});
errdefer msg.destroy(sema.gpa);
@ -23553,7 +23593,7 @@ fn resolveStructLayout(
switch (struct_obj.status) {
.none, .have_field_types => {},
.field_types_wip, .layout_wip => {
return sema.fail(block, src, "struct {} depends on itself", .{ty.fmt(sema.mod)});
return sema.fail(block, src, "struct '{}' depends on itself", .{ty.fmt(sema.mod)});
},
.have_layout, .fully_resolved_wip, .fully_resolved => return,
}
@ -23584,7 +23624,7 @@ fn resolveUnionLayout(
switch (union_obj.status) {
.none, .have_field_types => {},
.field_types_wip, .layout_wip => {
return sema.fail(block, src, "union {} depends on itself", .{ty.fmt(sema.mod)});
return sema.fail(block, src, "union '{}' depends on itself", .{ty.fmt(sema.mod)});
},
.have_layout, .fully_resolved_wip, .fully_resolved => return,
}
@ -23752,7 +23792,7 @@ fn resolveTypeFieldsStruct(
switch (struct_obj.status) {
.none => {},
.field_types_wip => {
return sema.fail(block, src, "struct {} depends on itself", .{ty.fmt(sema.mod)});
return sema.fail(block, src, "struct '{}' depends on itself", .{ty.fmt(sema.mod)});
},
.have_field_types,
.have_layout,
@ -23782,7 +23822,7 @@ fn resolveTypeFieldsUnion(
switch (union_obj.status) {
.none => {},
.field_types_wip => {
return sema.fail(block, src, "union {} depends on itself", .{ty.fmt(sema.mod)});
return sema.fail(block, src, "union '{}' depends on itself", .{ty.fmt(sema.mod)});
},
.have_field_types,
.have_layout,
@ -25005,7 +25045,7 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr
// The type is not in-memory coercible or the direct dereference failed, so it must
// be bitcast according to the pointer type we are performing the load through.
if (!load_ty.hasWellDefinedLayout())
return sema.fail(block, src, "comptime dereference requires {} to have a well-defined layout, but it does not.", .{load_ty.fmt(sema.mod)});
return sema.fail(block, src, "comptime dereference requires '{}' to have a well-defined layout, but it does not.", .{load_ty.fmt(sema.mod)});
const load_sz = try sema.typeAbiSize(block, src, load_ty);
@ -25020,11 +25060,11 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr
if (deref.ty_without_well_defined_layout) |bad_ty| {
// We got no parent for bit-casting, or the parent we got was too small. Either way, the problem
// is that some type we encountered when de-referencing does not have a well-defined layout.
return sema.fail(block, src, "comptime dereference requires {} to have a well-defined layout, but it does not.", .{bad_ty.fmt(sema.mod)});
return sema.fail(block, src, "comptime dereference requires '{}' to have a well-defined layout, but it does not.", .{bad_ty.fmt(sema.mod)});
} else {
// If all encountered types had well-defined layouts, the parent is the root decl and it just
// wasn't big enough for the load.
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) });
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) });
}
}
@ -25032,7 +25072,7 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr
/// is too big to fit.
fn usizeCast(sema: *Sema, block: *Block, src: LazySrcLoc, int: u64) CompileError!usize {
if (@bitSizeOf(u64) <= @bitSizeOf(usize)) return int;
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});
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});
}
/// For pointer-like optionals, it returns the pointer type. For pointers,
@ -25387,7 +25427,7 @@ fn anonStructFieldIndex(
return @intCast(u32, i);
}
}
return sema.fail(block, field_src, "anonymous struct {} has no such field '{s}'", .{
return sema.fail(block, field_src, "anonymous struct '{}' has no such field '{s}'", .{
struct_ty.fmt(sema.mod), field_name,
});
}
@ -25768,7 +25808,7 @@ fn floatToIntScalar(
try Value.Tag.int_big_positive.create(sema.arena, result_limbs);
if (!(try sema.intFitsInType(block, src, result, int_ty))) {
return sema.fail(block, src, "float value {} cannot be stored in integer type '{}'", .{
return sema.fail(block, src, "float value '{}' cannot be stored in integer type '{}'", .{
val.fmtValue(float_ty, sema.mod), int_ty.fmt(sema.mod),
});
}

View File

@ -409,11 +409,11 @@ pub fn print(
}
return writer.writeAll(" }");
},
.float_16 => return writer.print("{}", .{val.castTag(.float_16).?.data}),
.float_32 => return writer.print("{}", .{val.castTag(.float_32).?.data}),
.float_64 => return writer.print("{}", .{val.castTag(.float_64).?.data}),
.float_80 => return writer.print("{}", .{val.castTag(.float_80).?.data}),
.float_128 => return writer.print("{}", .{val.castTag(.float_128).?.data}),
.float_16 => return writer.print("{d}", .{val.castTag(.float_16).?.data}),
.float_32 => return writer.print("{d}", .{val.castTag(.float_32).?.data}),
.float_64 => return writer.print("{d}", .{val.castTag(.float_64).?.data}),
.float_80 => return writer.print("{d}", .{@floatCast(f64, val.castTag(.float_80).?.data)}),
.float_128 => return writer.print("{d}", .{@floatCast(f64, val.castTag(.float_128).?.data)}),
.@"error" => return writer.print("error.{s}", .{val.castTag(.@"error").?.data.name}),
.eu_payload => {
val = val.castTag(.eu_payload).?.data;

View File

@ -2,4 +2,4 @@ pub export fn main() noreturn {}
// error
//
// :1:32: error: expected noreturn, found void
// :1:32: error: expected type 'noreturn', found 'void'

View File

@ -9,8 +9,8 @@ export fn f2(x: V(4, u32)) V(4, u32) {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:12: error: negation of type 'u32'
// tmp.zig:8:12: error: negation of type 'u32'
// :3:12: error: negation of type 'u32'
// :8:12: error: negation of type '@Vector(4, u32)'

View File

@ -4,7 +4,7 @@ fn foo() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:28: error: '.*' cannot be followed by '*'. Are you missing a space?
// :2:28: error: '.*' cannot be followed by '*'. Are you missing a space?

View File

@ -4,8 +4,8 @@ test "Crash" {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:1:11: error: use of undeclared identifier 'B'
// :1:11: error: use of undeclared identifier 'B'

View File

@ -0,0 +1,12 @@
const Foo = error{A};
comptime {
const z = Foo.Bar;
_ = z;
}
// error
// backend=stage2
// target=native
//
// :3:18: error: no error named 'Bar' in 'error{A}'
// :1:13: note: error set declared here

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
a += a;
}
// error
// backend=stage2
// target=native
//
// :3:10: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = a + a;
}
// error
// backend=stage2
// target=native
//
// :3:13: error: use of undefined value here causes undefined behavior

View File

@ -6,7 +6,8 @@ fn add(a: u16, b: u16) u16 {
export fn entry() usize { return @sizeOf(@TypeOf(y)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:14: error: operation caused overflow
// :3:14: error: overflow of integer type 'u16' with value '65540'
// :1:14: note: called from here

View File

@ -6,7 +6,7 @@ const x = Foo {.field = 1} + Foo {.field = 2};
export fn entry() usize { return @sizeOf(@TypeOf(x)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo'
// :4:28: error: invalid operands to binary expression: 'Struct' and 'Struct'

View File

@ -0,0 +1,10 @@
const x = 3;
const y = &x;
fn foo() *const i32 { return y; }
export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
// error
// backend=stage2
// target=native
//
// :3:30: error: expected type '*const i32', found '*const comptime_int'

View File

@ -3,7 +3,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:19: error: expected pointer or slice, found 'u32'
// :2:19: error: expected pointer type, found 'u32'

View File

@ -8,7 +8,7 @@ export fn entry1() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:7: error: expected ',' after field
// :3:7: error: expected ',' after field

View File

@ -13,9 +13,9 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:13: error: ambiguous reference
// tmp.zig:7:9: note: declared here
// tmp.zig:1:1: note: also declared here
// :5:13: error: ambiguous reference
// :7:9: note: declared here
// :1:1: note: also declared here

View File

@ -8,4 +8,4 @@ pub fn main() void {
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos
//
// :3:21: error: expected *anyopaque, found ?usize
// :3:21: error: expected type '*anyopaque', found '?usize'

View File

@ -0,0 +1,9 @@
export fn f() void {
i[i] = i[i];
}
// error
// backend=stage2
// target=native
//
// :2:5: error: use of undeclared identifier 'i'

View File

@ -5,7 +5,7 @@ const a = derp ++ "foo";
export fn entry() usize { return @sizeOf(@TypeOf(a)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:11: error: expected array, found 'usize'
// :3:11: error: expected indexable; found 'usize'

View File

@ -11,7 +11,7 @@ fn doSomeAsm() void {
}
// error
// backend=stage1
// backend=llvm
// target=native
//
// tmp.zig:6:5: error: unable to evaluate constant expression
// :6:5: error: unable to evaluate constant expression

View File

@ -3,7 +3,7 @@ const a: *u8 = null;
export fn entry() usize { return @sizeOf(@TypeOf(a)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:16: error: expected type '*u8', found '@Type(.Null)'
// :1:16: error: expected type '*u8', found '@TypeOf(null)'

View File

@ -4,7 +4,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:13: error: cannot assign to constant
// :3:13: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:13: error: cannot assign to constant
// :3:13: error: cannot assign to constant

View File

@ -7,7 +7,7 @@ export fn derp() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:6:15: error: cannot assign to constant
// :6:15: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:9: error: cannot assign to constant
// :3:9: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn foo() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:24: error: integer value 753664 cannot be coerced to type 'u16'
// :2:24: error: type 'u16' cannot represent integer value '753664'

View File

@ -0,0 +1,11 @@
export fn f() void {
const a = return;
_ = a;
}
// error
// backend=stage2
// target=native
//
// :2:5: error: unreachable code
// :2:15: note: control flow is diverted here

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:30: error: @atomicStore atomic ordering must not be Acquire or AcqRel
// :3:31: error: @atomicStore atomic ordering must not be Acquire or AcqRel

View File

@ -5,7 +5,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:4:81: error: failure atomic ordering must be no stricter than success
// :4:81: error: failure atomic ordering must be no stricter than success

View File

@ -5,7 +5,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:4:58: error: success atomic ordering must be Monotonic or stricter
// :4:58: error: success atomic ordering must be Monotonic or stricter

View File

@ -0,0 +1,9 @@
export fn entry() void {
@fence(.Monotonic);
}
// error
// backend=stage2
// target=native
//
// :2:13: error: atomic ordering must be Acquire or stricter

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:30: error: @atomicRmw with bool only allowed with .Xchg
// :3:31: error: @atomicRmw with bool only allowed with .Xchg

View File

@ -10,7 +10,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:9:27: error: @atomicRmw with enum only allowed with .Xchg
// :9:28: error: @atomicRmw with enum only allowed with .Xchg

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:29: error: @atomicRmw with float only allowed with .Xchg, .Add and .Sub
// :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, and .Sub

View File

@ -5,7 +5,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:9: error: expected type 'error{Hi}', found '@Type(.EnumLiteral)'
// :3:10: error: expected type 'error{Hi}', found '@TypeOf(.enum_literal)'

View File

@ -0,0 +1,14 @@
fn SimpleList(comptime L: usize) type {
var T = u8;
return struct {
array: [L]T,
};
}
// error
// backend=stage2
// target=native
//
// :4:19: error: mutable 'T' not accessible from here
// :2:9: note: declared mutable here
// :3:12: note: crosses namespace boundary here

View File

@ -4,7 +4,7 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:16: error: 17-bit float unsupported
// :3:9: error: 17-bit float unsupported

View File

@ -0,0 +1,12 @@
export fn entry(a: bool, b: bool) i32 {
if (a && b) {
return 1234;
}
return 5678;
}
// error
// backend=stage2
// target=native
//
// :2:11: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND

View File

@ -0,0 +1,13 @@
export fn entry(a: bool, b: bool) i32 {
if (a || b) {
return 1234;
}
return 5678;
}
// error
// backend=stage2
// target=native
//
// :2:9: error: expected error set type, found 'bool'
// :2:11: note: '||' merges error sets; 'or' performs boolean OR

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:30: error: expected type '[*]const bool', found 'bool'
// :2:30: error: expected type '[*]const bool', found 'bool'

View File

@ -5,7 +5,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:23: error: expected type '[]u32', found '*const u32'
// :3:22: error: expected type '[]u32', found '*const u32'

View File

@ -11,7 +11,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:8:5: error: use of undeclared identifier 'bogus'
// :8:5: error: use of undeclared identifier 'bogus'

View File

@ -0,0 +1,7 @@
const bogus = @import("bogus-does-not-exist.zig",);
// error
// backend=stage2
// target=native
//
// :1:23: error: unable to load '${DIR}bogus-does-not-exist.zig': FileNotFound

View File

@ -0,0 +1,11 @@
export fn entry() void {
const c = 4;
var v = @splat(4, c);
_ = v;
}
// error
// backend=stage2
// target=native
//
// :3:23: error: expected integer, float, bool, or pointer for the vector element type; found 'comptime_int'

View File

@ -6,8 +6,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'
// :2:18: error: invalid operands to binary bitwise expression: 'ErrorSet' and 'ErrorSet'

View File

@ -5,7 +5,7 @@ var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE -
export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:60: error: unable to perform binary not operation on type 'comptime_int'
// :3:60: error: unable to perform binary not operation on type 'comptime_int'

View File

@ -0,0 +1,10 @@
export fn entry(byte: u8) void {
var oops = @bitCast(u7, byte);
_ = oops;
}
// error
// backend=stage2
// target=native
//
// :2:29: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits

View File

@ -0,0 +1,10 @@
export fn entry() void {
var foo = (@bitCast(u8, @as(f32, 1.0)) == 0xf);
_ = foo;
}
// error
// backend=stage2
// target=native
//
// :2:29: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits

View File

@ -0,0 +1,10 @@
export fn entry() void {
const x = &@as(u8, 1) << 10;
_ = x;
}
// error
// backend=stage2
// target=native
//
// :2:15: error: bit shifting operation expected integer type, found '*const u8'

View File

@ -0,0 +1,11 @@
var self = "aoeu";
fn f(m: []const u8) void {
m.copy(u8, self[0..], m);
}
export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
// error
// backend=stage2
// target=native
//
// :3:6: error: type '[]const u8' has no field or member function named 'copy'

View File

@ -3,7 +3,7 @@ const x = if (undefined) true else false;
export fn entry() usize { return @sizeOf(@TypeOf(x)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:15: error: use of undefined value here causes undefined behavior
// :1:15: error: use of undefined value here causes undefined behavior

View File

@ -17,8 +17,8 @@ export fn entry1() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:12:14: error: cannot assign to constant
// tmp.zig:16:14: error: cannot assign to constant
// :12:14: error: cannot assign to constant
// :16:14: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn entry() void {
pub extern fn foo(format: *const u8, ...) void;
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:16: error: expected type '*const u8', found '[5:0]u8'
// :2:8: error: expected type '*const u8', found '[5:0]u8'

View File

@ -8,8 +8,8 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:6:20: error: enum 'Foo' has no field named 'c'
// tmp.zig:1:13: note: 'Foo' declared here
// :6:21: error: enum 'tmp.Foo' has no field named 'c'
// :1:13: note: enum declared here

View File

@ -0,0 +1,10 @@
export fn entry() void {
const x = @as(usize, -10);
_ = x;
}
// error
// backend=stage2
// target=native
//
// :2:26: error: type 'usize' cannot represent integer value '-10'

View File

@ -10,8 +10,8 @@ export fn entry1() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:22: error: attempt to cast negative value to unsigned integer
// tmp.zig:8:27: error: cannot cast negative value -1 to unsigned integer type 'u32'
// :3:36: error: type 'u32' cannot represent integer value '-1'
// :8:27: error: type 'u32' cannot represent integer value '-1'

View File

@ -0,0 +1,13 @@
fn f() i32 {
return @as(i32, return 1);
}
export fn entry() void { _ = f(); }
// error
// backend=stage2
// target=native
//
// :2:12: error: unreachable code
// :2:21: note: control flow is diverted here
// :2:5: error: unreachable code
// :2:12: note: control flow is diverted here

View File

@ -12,10 +12,10 @@ fn bar(x: *const u3) u3 {
return x.*;
}
export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'
// :8:15: error: expected type '*const u3', found '*align(0:3:1) const u3'

View File

@ -3,7 +3,7 @@ export fn a(value: u32) bool {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:22: error: comparison operators cannot be chained
// :2:22: error: comparison operators cannot be chained

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32'
// :3:22: error: expected bool, integer, enum, or pointer type; found 'f32'

View File

@ -0,0 +1,12 @@
fn func() bogus {}
fn func() bogus {}
export fn entry() usize { return @sizeOf(@TypeOf(func)); }
// error
// backend=stage2
// target=native
//
// :2:1: error: redeclaration of 'func'
// :1:1: note: other declaration here
// :1:11: error: use of undeclared identifier 'bogus'
// :2:11: error: use of undeclared identifier 'bogus'

View File

@ -8,9 +8,8 @@ export fn entry() void {
fn foo() void {}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:4:9: error: suspend inside nosuspend block
// tmp.zig:2:5: note: nosuspend block here
// :4:9: error: suspend inside nosuspend block
// :2:5: note: nosuspend block here

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:12: error: comparison of '*i32' with null
// :3:12: error: comparison of '*i32' with null

View File

@ -36,12 +36,12 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:11: error: use of undefined value here causes undefined behavior
// tmp.zig:11:11: error: use of undefined value here causes undefined behavior
// tmp.zig:17:11: error: use of undefined value here causes undefined behavior
// tmp.zig:23:11: error: use of undefined value here causes undefined behavior
// tmp.zig:29:11: error: use of undefined value here causes undefined behavior
// tmp.zig:35:11: error: use of undefined value here causes undefined behavior
// :5:11: error: use of undefined value here causes undefined behavior
// :11:11: error: use of undefined value here causes undefined behavior
// :17:11: error: use of undefined value here causes undefined behavior
// :23:11: error: use of undefined value here causes undefined behavior
// :29:11: error: use of undefined value here causes undefined behavior
// :35:11: error: use of undefined value here causes undefined behavior

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:25: error: operator not allowed for type 'anyerror!i32'
// :3:25: error: operator == not allowed for type 'anyerror!i32'

View File

@ -8,7 +8,7 @@ export fn entry() i32 {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:13: error: aoeu
// :1:13: error: aoeu

View File

@ -10,7 +10,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:14: error: use of undeclared identifier 'crap'
// :2:14: error: use of undeclared identifier 'crap'

View File

@ -8,7 +8,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist'
// :2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist'

View File

@ -3,7 +3,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:5: error: found compile log statement
// :2:5: error: found compile log statement

View File

@ -8,7 +8,8 @@ fn inner(comptime n: usize) void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:7:39: error: found compile log statement
// :7:39: error: found compile log statement
// :7:39: note: also here

View File

@ -0,0 +1,18 @@
const Letter = enum { A, B, C };
const Value = union(Letter) {
A: i32,
B,
C,
};
export fn entry() void {
var x: Value = Letter.A;
_ = x;
}
// error
// backend=stage2
// target=native
//
// :8:26: error: coercion from enum 'tmp.Letter' to union 'tmp.Value' must initialize 'i32' field 'A'
// :3:5: note: field 'A' declared here
// :2:15: note: union declared here

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:41: error: non-zero length slice of undefined pointer
// :2:41: error: non-zero length slice of undefined pointer

View File

@ -7,7 +7,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:5: error: comptime field without default initialization value
// :2:5: error: comptime field without default initialization value

View File

@ -0,0 +1,9 @@
export fn f() void {
(const a = 0);
}
// error
// backend=stage2
// target=native
//
// :2:6: error: expected expression, found 'const'

View File

@ -4,7 +4,7 @@ const a = zero{1};
export fn entry() usize { return @sizeOf(@TypeOf(a)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:11: error: expected type 'type', found 'i32'
// :2:15: error: expected type 'type', found 'i32'

View File

@ -0,0 +1,15 @@
export fn foo() void {
comptime var i = 0;
while (i < 5) : (i += 1) {
bar();
}
}
fn bar() void { }
// error
// backend=stage2
// target=native
//
// :3:24: error: cannot store to comptime variable in non-inline loop
// :3:5: note: non-inline loop here

View File

@ -16,9 +16,9 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:9:5: error: declarations are not allowed between container fields
// tmp.zig:5:5: note: field before declarations here
// tmp.zig:12:5: note: field after declarations here
// :9:5: error: declarations are not allowed between container fields
// :5:5: note: field before declarations here
// :12:5: note: field after declarations here

View File

@ -0,0 +1,12 @@
const u8 = u16;
export fn entry() void {
const a: u8 = 300;
_ = a;
}
// error
// backend=stage2
// target=native
//
// :1:7: error: name shadows primitive 'u8'
// :1:7: note: consider using @"u8" to disambiguate

View File

@ -0,0 +1,13 @@
export fn a() void {
x += 1;
}
export fn b() void {
x += 1;
}
// error
// backend=stage2
// target=native
//
// :2:5: error: use of undeclared identifier 'x'
// :5:5: error: use of undeclared identifier 'x'

View File

@ -7,7 +7,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:29: error: expected type '*anyopaque', found '**u32'
// :5:28: error: expected type '*anyopaque', found '**u32'

View File

@ -16,8 +16,8 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:9: error: duplicate switch value
// tmp.zig:13:9: error: duplicate switch value
// :5:9: error: duplicate switch value
// :13:9: error: duplicate switch value

View File

@ -8,8 +8,8 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: duplicate error set field 'Bar'
// tmp.zig:2:5: note: previous declaration here
// :3:5: error: duplicate error set field 'Bar'
// :2:5: note: previous declaration here

View File

@ -14,7 +14,8 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:11:9: error: duplicate field
// :11:10: error: duplicate field
// :8:10: note: other field here

View File

@ -8,8 +8,9 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: duplicate struct field: 'Bar'
// tmp.zig:2:5: note: other field here
// :3:5: error: duplicate struct field: 'Bar'
// :2:5: note: other field here
// :1:13: note: struct declared here

View File

@ -8,8 +8,9 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: duplicate union field: 'Bar'
// tmp.zig:2:5: note: other field here
// :3:5: error: duplicate union field: 'Bar'
// :2:5: note: other field here
// :1:13: note: union declared here

View File

@ -3,7 +3,7 @@ const resource = @embedFile("bogus.txt",);
export fn entry() usize { return @sizeOf(@TypeOf(resource)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:29: error: unable to find '
// :1:29: error: unable to open 'bogus.txt': FileNotFound

View File

@ -0,0 +1,9 @@
export fn a() void {
for(undefined) |x|;
}
// error
// backend=stage2
// target=native
//
// :2:23: error: expected block or assignment, found ';'

View File

@ -0,0 +1,9 @@
export fn a() void {
if(true);
}
// error
// backend=stage2
// target=native
//
// :2:13: error: expected block or assignment, found ';'

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: switch must handle all possibilities
// :3:5: error: switch must handle all possibilities

View File

@ -0,0 +1,9 @@
export fn a() void {
while(true);
}
// error
// backend=stage2
// target=native
//
// :2:16: error: expected block or assignment, found ';'

View File

@ -6,7 +6,9 @@ fn fibonacci(x: i32) i32 {
export fn entry() usize { return @sizeOf(@TypeOf(seventh_fib_number)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:21: error: evaluation exceeded 1000 backwards branches
// :3:21: error: evaluation exceeded 1000 backwards branches
// :3:21: note: called from here (999 times)
// :1:37: note: called from here

View File

@ -8,8 +8,8 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:6:13: error: enum 'Foo' has no tag matching integer value 0
// tmp.zig:1:13: note: 'Foo' declared here
// :6:13: error: enum 'tmp.Foo' has no tag with value '0'
// :1:13: note: enum declared here

View File

@ -0,0 +1,7 @@
const Foo = enum {};
// error
// backend=stage2
// target=native
//
// :1:13: error: enum declarations must have at least one tag

View File

@ -3,7 +3,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:15: error: Type.Enum.decls must be empty for @Type
// :2:9: error: reified enums must have no decls

View File

@ -8,8 +8,9 @@ pub export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:4:9: error: duplicate struct field: 'e'
// :4:9: error: duplicate struct field: 'e'
// :3:9: note: other field here
// :2:22: note: struct declared here

View File

@ -5,7 +5,7 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:15: error: expected error set type, found type 'i32'
// :2:15: error: expected error set type, found 'i32'

View File

@ -4,8 +4,7 @@ pub export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:3:26: error: expected 2 arguments, found 1
// :3:26: error: expected 2 arguments, found 1

View File

@ -0,0 +1,15 @@
export fn entry1() void {
const T = u65536;
_ = T;
}
export fn entry2() void {
var x: i65536 = 1;
_ = x;
}
// error
// backend=stage2
// target=native
//
// :2:15: error: primitive integer type 'u65536' exceeds maximum bit width of 65535
// :6:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535

View File

@ -0,0 +1,9 @@
export fn entry() i32 {
return @as(i32, 12.34);
}
// error
// backend=stage2
// target=native
//
// :2:21: error: fractional component prevents float value '12.34' from coercion to type 'i32'

View File

@ -7,7 +7,8 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:13: error: error.B not a member of error set 'Set2'
// :5:13: error: 'error.B' not a member of error set 'error{A,C}'
// :2:14: note: error set declared here

Some files were not shown because too many files have changed in this diff Show More