╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ compile_errors.zig ───────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
108 case.addSourceFile("a.zig", 109 \\pub const S = struct { 110 \\ comptime foo: u32 = 1, 111 \\ bar: u32, 112 \\ pub fn qux(x: @This()) void { 113 \\ _ = x; 114 \\ } 115 \\}; 116 ); 117 } 118 119 { 120 const case = ctx.obj("file in multiple modules", b.graph.host); 121 case.addDepModule("foo", "foo.zig"); 122 123 case.addError( 124 \\comptime { 125 \\ _ = @import("foo"); 126 \\ _ = @import("foo.zig"); 127 \\} 128 , &[_][]const u8{ 129 "foo.zig:1:1: error: file exists in modules 'foo' and 'root'", 130 "foo.zig:1:1: note: files must belong to only one module", 131 "foo.zig:1:1: note: file is the root of module 'foo'", 132 "tmp.zig:3:17: note: file is imported here by the root of module 'root'", 133 }); 134 case.addSourceFile("foo.zig", 135 \\const dummy = 0; 136 ); 137 } 138 139 { 140 const case = ctx.obj("wrong same named struct", b.graph.host); 141 142 case.addError( 143 \\const a = @import("a.zig"); 144 \\const b = @import("b.zig"); 145 \\ 146 \\export fn entry() void { 147 \\ var a1: a.Foo = undefined; 148 \\ bar(&a1); 149 \\} 150 \\ 151 \\fn bar(_: *b.Foo) void {} 152 , &[_][]const u8{ 153 ":6:9: error: expected type '*b.Foo', found '*a.Foo'", 154 ":6:9: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'", 155 ":1:17: note: struct declared here", 156 ":1:17: note: struct declared here", 157 ":9:11: note: parameter type declared here", 158 }); 159 160 case.addSourceFile("a.zig", 161 \\pub const Foo = struct { 162 \\ x: i32, 163 \\}; 164 ); 165 166 case.addSourceFile("b.zig", 167 \\pub const Foo = struct { 168 \\ z: f64, 169 \\}; 170 ); 171 } 172 173 { 174 const case = ctx.obj("non-printable invalid character", b.graph.host); 175 176 case.addError("\xff\xfe" ++ 177 \\export fn foo() bool { 178 \\ return true; 179 \\} 180 , &[_][]const u8{ 181 ":1:1: error: expected type expression, found 'invalid token'", 182 }); 183 } 184 185 { 186 const case = ctx.obj("imported generic method call with invalid param", b.graph.host); 187 188 case.addError( 189 \\pub const import = @import("import.zig"); 190 \\ 191 \\export fn callComptimeBoolFunctionWithRuntimeBool(x: bool) void { 192 \\ import.comptimeBoolFunction(x); 193 \\} 194 \\ 195 \\export fn callComptimeAnytypeFunctionWithRuntimeBool(x: bool) void { 196 \\ import.comptimeAnytypeFunction(x); 197 \\} 198 \\ 199 \\export fn callAnytypeFunctionWithRuntimeComptimeOnlyType(x: u32) void { 200 \\ const S = struct { x: u32, y: type }; 201 \\ import.anytypeFunction(S{ .x = x, .y = u32 }); 202 \\} 203 , &[_][]const u8{ 204 ":4:33: error: unable to resolve comptime value", 205 ":4:33: note: argument to comptime parameter must be comptime-known", 206 ":1:29: note: parameter declared comptime here", 207 ":8:36: error: unable to resolve comptime value", 208 ":8:36: note: argument to comptime parameter must be comptime-known", 209 ":2:32: note: parameter declared comptime here", 210 ":13:32: error: unable to resolve comptime value", 211 ":13:32: note: initializer of comptime-only struct 'tmp.callAnytypeFunctionWithRuntimeComptimeOnlyType.S' must be comptime-known", 212 ":12:35: note: struct requires comptime because of this field", 213 ":12:35: note: types are not available at runtime", 214 }); 215 216 case.addSourceFile("import.zig", 217 \\pub fn comptimeBoolFunction(comptime _: bool) void {} 218 \\pub fn comptimeAnytypeFunction(comptime _: anytype) void {} 219 \\pub fn anytypeFunction(_: anytype) void {} 220 ); 221 } 222 223 { 224 const case = ctx.obj("invalid byte in string", b.graph.host); 225 226 case.addError("_ = \"\x01Q\";", &[_][]const u8{ 227 ":1:6: error: string literal contains invalid byte: '\\x01'", 228 }); 229 } 230 231 { 232 const case = ctx.obj("invalid byte in comment", b.graph.host); 233 234 case.addError("//\x01Q", &[_][]const u8{ 235 ":1:3: error: comment contains invalid byte: '\\x01'", 236 }); 237 } 238 239 { 240 const case = ctx.obj("control character in character literal", b.graph.host); 241 242 case.addError("const c = '\x01';", &[_][]const u8{ 243 ":1:12: error: character literal contains invalid byte: '\\x01'", 244 }); 245 } 246 247 { 248 const case = ctx.obj("invalid byte at start of token", b.graph.host); 249 250 case.addError("x = \x00Q", &[_][]const u8{ 251 ":1:5: error: expected expression, found 'invalid token'", 252 }); 253 } 254 } 255