aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-01-14 12:50:46 +0200
committerVeikka Tuominen <git@vexu.eu>2023-01-17 20:28:43 +0200
commit94be9dcc7f2ff81c3433cd2f8bb32f7ea53ba7cf (patch)
treeeb67ac3a71c5fda6ac38271c5e8d02598fda867d
parent6e067dc0506c8d5342ddaa0934770f7339619d36 (diff)
downloadzig-94be9dcc7f2ff81c3433cd2f8bb32f7ea53ba7cf.tar.gz
zig-94be9dcc7f2ff81c3433cd2f8bb32f7ea53ba7cf.zip
enable passing compile error test
-rw-r--r--test/cases/compile_errors/invalid_store_to_comptime_field.zig19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/cases/compile_errors/invalid_store_to_comptime_field.zig b/test/cases/compile_errors/invalid_store_to_comptime_field.zig
index 89deda92d4..0f444ba78c 100644
--- a/test/cases/compile_errors/invalid_store_to_comptime_field.zig
+++ b/test/cases/compile_errors/invalid_store_to_comptime_field.zig
@@ -44,15 +44,15 @@ pub export fn entry5() void {
comptime var y = .{ 1, 2 };
y = .{ 3, 4 };
}
-// pub export fn entry5() void {
-// var x: u32 = 15;
-// const T = @TypeOf(.{ @as(i32, -1234), @as(u32, 5678), x });
-// const S = struct {
-// fn foo(_: T) void {}
-// };
-// _ = S.foo(.{ -1234, 5679, x });
-// }
pub export fn entry6() void {
+ var x: u32 = 15;
+ const T = @TypeOf(.{ @as(i32, -1234), @as(u32, 5678), x });
+ const S = struct {
+ fn foo(_: T) void {}
+ };
+ _ = S.foo(.{ -1234, 5679, x });
+}
+pub export fn entry7() void {
const State = struct {
comptime id: bool = true,
fn init(comptime id: bool) @This() {
@@ -61,7 +61,7 @@ pub export fn entry6() void {
};
_ = State.init(false);
}
-pub export fn entry7() void {
+pub export fn entry8() void {
const list1 = .{ "sss", 1, 2, 3 };
const list2 = @TypeOf(list1){ .@"0" = "xxx", .@"1" = 4, .@"2" = 5, .@"3" = 6 };
_ = list2;
@@ -73,6 +73,7 @@ pub export fn entry7() void {
//
// :6:19: error: value stored in comptime field does not match the default value of the field
// :14:19: error: value stored in comptime field does not match the default value of the field
+// :53:16: error: value stored in comptime field does not match the default value of the field
// :19:38: error: value stored in comptime field does not match the default value of the field
// :31:19: error: value stored in comptime field does not match the default value of the field
// :25:29: note: default value set here