Closed
Description
Hi !
When playing with the JSON parser of the standard library, I came across an undected "undeclared identifier" error with the following snippet:
const warn = @import("std").debug.warn;
const json = std.json;
pub fn main() void {
warn("Hello World!\n");
}
At line 2 const json = std.json;
the std
is not declared but the program compile and run fine.
It is only when I try to call something from the json variable that the error is detected:
const warn = @import("std").debug.warn;
const json = std.json;
pub fn main() void {
warn("Hello World!\n");
var p = json.TokenStream.init(json_source);
}
The previous snippets produce the expected error:
➜ zig build-exe hello.zig
path/to/hello.zig:6:34: error: use of undeclared identifier 'json_source'
var p = json.TokenStream.init(json_source);
^