Skip to content

Undectected "undeclared identifier" error #1674

Closed
@ducdetronquito

Description

@ducdetronquito

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);
                                                   ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    use caseDescribes a real use case that is difficult or impossible, but does not propose a solution.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions