| ... | ... | @@ -2186,4 +2186,49 @@ pub fn addCases(cases: &tests.CompileErrorContext) { |
| 2186 | 2186 | , |
| 2187 | 2187 | ".tmp_source.zig:3:5: error: alignstack set twice", |
| 2188 | 2188 | ".tmp_source.zig:2:5: note: first set here"); |
| 2189 | |
| 2190 | cases.add("storing runtime value in compile time variable then using it", |
| 2191 | \\const Mode = @import("builtin").Mode; |
| 2192 | \\ |
| 2193 | \\fn Free(comptime filename: []const u8) -> TestCase { |
| 2194 | \\ TestCase { |
| 2195 | \\ .filename = filename, |
| 2196 | \\ .problem_type = ProblemType.Free, |
| 2197 | \\ } |
| 2198 | \\} |
| 2199 | \\ |
| 2200 | \\fn LibC(comptime filename: []const u8) -> TestCase { |
| 2201 | \\ TestCase { |
| 2202 | \\ .filename = filename, |
| 2203 | \\ .problem_type = ProblemType.LinkLibC, |
| 2204 | \\ } |
| 2205 | \\} |
| 2206 | \\ |
| 2207 | \\const TestCase = struct { |
| 2208 | \\ filename: []const u8, |
| 2209 | \\ problem_type: ProblemType, |
| 2210 | \\}; |
| 2211 | \\ |
| 2212 | \\const ProblemType = enum { |
| 2213 | \\ Free, |
| 2214 | \\ LinkLibC, |
| 2215 | \\}; |
| 2216 | \\ |
| 2217 | \\export fn entry() { |
| 2218 | \\ const tests = []TestCase { |
| 2219 | \\ Free("001"), |
| 2220 | \\ Free("002"), |
| 2221 | \\ LibC("078"), |
| 2222 | \\ Free("116"), |
| 2223 | \\ Free("117"), |
| 2224 | \\ }; |
| 2225 | \\ |
| 2226 | \\ for ([]Mode { Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast }) |mode| { |
| 2227 | \\ inline for (tests) |test_case| { |
| 2228 | \\ const foo = test_case.filename ++ ".zig"; |
| 2229 | \\ } |
| 2230 | \\ } |
| 2231 | \\} |
| 2232 | , |
| 2233 | ".tmp_source.zig:37:16: error: cannot store runtime value in compile time variable"); |
| 2189 | 2234 | } |