| ... | @@ -3880,7 +3880,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -3880,7 +3880,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3880 | \\ return 2; | 3880 | \\ return 2; |
| 3881 | \\} | 3881 | \\} |
| 3882 | , | 3882 | , |
| 3883 | "tmp.zig:2:15: error: values of type 'comptime_int' must be comptime known", | 3883 | "tmp.zig:5:17: error: cannot store runtime value in type 'comptime_int'", |
| 3884 | ); | 3884 | ); |
| 3885 | | 3885 | |
| 3886 | cases.add( | 3886 | cases.add( |
| ... | @@ -5132,7 +5132,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5132,7 +5132,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5132 | \\ const array = [2]u8{1, 2, 3}; | 5132 | \\ const array = [2]u8{1, 2, 3}; |
| 5133 | \\} | 5133 | \\} |
| 5134 | , | 5134 | , |
| 5135 | "tmp.zig:2:24: error: expected [2]u8 literal, found [3]u8 literal", | 5135 | "tmp.zig:2:31: error: index 2 outside array of size 2", |
| 5136 | ); | 5136 | ); |
| 5137 | | 5137 | |
| 5138 | cases.add( | 5138 | cases.add( |
| ... | @@ -5149,36 +5149,47 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5149,36 +5149,47 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5149 | | 5149 | |
| 5150 | cases.add( | 5150 | cases.add( |
| 5151 | "non-const variables of things that require const variables", | 5151 | "non-const variables of things that require const variables", |
| 5152 | \\const Opaque = @OpaqueType(); | 5152 | \\export fn entry1() void { |
| 5153 | \\ | | |
| 5154 | \\export fn entry(opaque: *Opaque) void { | | |
| 5155 | \\ var m2 = &2; | 5153 | \\ var m2 = &2; |
| 5156 | \\ const y: u32 = m2.*; | 5154 | \\} |
| 5157 | \\ | 5155 | \\export fn entry2() void { |
| 5158 | \\ var a = undefined; | 5156 | \\ var a = undefined; |
| | 5157 | \\} |
| | 5158 | \\export fn entry3() void { |
| 5159 | \\ var b = 1; | 5159 | \\ var b = 1; |
| | 5160 | \\} |
| | 5161 | \\export fn entry4() void { |
| 5160 | \\ var c = 1.0; | 5162 | \\ var c = 1.0; |
| | 5163 | \\} |
| | 5164 | \\export fn entry5() void { |
| 5161 | \\ var d = null; | 5165 | \\ var d = null; |
| | 5166 | \\} |
| | 5167 | \\export fn entry6(opaque: *Opaque) void { |
| 5162 | \\ var e = opaque.*; | 5168 | \\ var e = opaque.*; |
| | 5169 | \\} |
| | 5170 | \\export fn entry7() void { |
| 5163 | \\ var f = i32; | 5171 | \\ var f = i32; |
| | 5172 | \\} |
| | 5173 | \\export fn entry8() void { |
| 5164 | \\ var h = (Foo {}).bar; | 5174 | \\ var h = (Foo {}).bar; |
| 5165 | \\ | 5175 | \\} |
| | 5176 | \\export fn entry9() void { |
| 5166 | \\ var z: noreturn = return; | 5177 | \\ var z: noreturn = return; |
| 5167 | \\} | 5178 | \\} |
| 5168 | \\ | 5179 | \\const Opaque = @OpaqueType(); |
| 5169 | \\const Foo = struct { | 5180 | \\const Foo = struct { |
| 5170 | \\ fn bar(self: *const Foo) void {} | 5181 | \\ fn bar(self: *const Foo) void {} |
| 5171 | \\}; | 5182 | \\}; |
| 5172 | , | 5183 | , |
| 5173 | "tmp.zig:4:4: error: variable of type '*comptime_int' must be const or comptime", | 5184 | "tmp.zig:2:4: error: variable of type '*comptime_int' must be const or comptime", |
| 5174 | "tmp.zig:7:4: error: variable of type '(undefined)' must be const or comptime", | 5185 | "tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime", |
| 5175 | "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime", | 5186 | "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime", |
| 5176 | "tmp.zig:9:4: error: variable of type 'comptime_float' must be const or comptime", | 5187 | "tmp.zig:11:4: error: variable of type 'comptime_float' must be const or comptime", |
| 5177 | "tmp.zig:10:4: error: variable of type '(null)' must be const or comptime", | 5188 | "tmp.zig:14:4: error: variable of type '(null)' must be const or comptime", |
| 5178 | "tmp.zig:11:4: error: variable of type 'Opaque' not allowed", | 5189 | "tmp.zig:17:4: error: variable of type 'Opaque' not allowed", |
| 5179 | "tmp.zig:12:4: error: variable of type 'type' must be const or comptime", | 5190 | "tmp.zig:20:4: error: variable of type 'type' must be const or comptime", |
| 5180 | "tmp.zig:13:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime", | 5191 | "tmp.zig:23:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime", |
| 5181 | "tmp.zig:15:4: error: unreachable code", | 5192 | "tmp.zig:26:4: error: unreachable code", |
| 5182 | ); | 5193 | ); |
| 5183 | | 5194 | |
| 5184 | cases.add( | 5195 | cases.add( |
| ... | @@ -5324,7 +5335,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5324,7 +5335,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5324 | \\ } | 5335 | \\ } |
| 5325 | \\} | 5336 | \\} |
| 5326 | , | 5337 | , |
| 5327 | "tmp.zig:37:16: error: cannot store runtime value in compile time variable", | 5338 | "tmp.zig:37:29: error: cannot store runtime value in compile time variable", |
| 5328 | ); | 5339 | ); |
| 5329 | | 5340 | |
| 5330 | cases.add( | 5341 | cases.add( |
| ... | @@ -5948,7 +5959,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5948,7 +5959,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5948 | \\ const foo = Foo { .Bar = x, .Baz = u8 }; | 5959 | \\ const foo = Foo { .Bar = x, .Baz = u8 }; |
| 5949 | \\} | 5960 | \\} |
| 5950 | , | 5961 | , |
| 5951 | "tmp.zig:7:30: error: unable to evaluate constant expression", | 5962 | "tmp.zig:7:23: error: unable to evaluate constant expression", |
| 5952 | ); | 5963 | ); |
| 5953 | | 5964 | |
| 5954 | cases.add( | 5965 | cases.add( |
| ... | @@ -5962,7 +5973,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5962,7 +5973,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5962 | \\ const foo = Foo { .Bar = x }; | 5973 | \\ const foo = Foo { .Bar = x }; |
| 5963 | \\} | 5974 | \\} |
| 5964 | , | 5975 | , |
| 5965 | "tmp.zig:7:30: error: unable to evaluate constant expression", | 5976 | "tmp.zig:7:23: error: unable to evaluate constant expression", |
| 5966 | ); | 5977 | ); |
| 5967 | | 5978 | |
| 5968 | cases.addTest( | 5979 | cases.addTest( |