Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make @import of a non-existing file a compile error #7867

Closed
vkcz opened this issue Jan 24, 2021 · 2 comments
Closed

make @import of a non-existing file a compile error #7867

vkcz opened this issue Jan 24, 2021 · 2 comments
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@vkcz
Copy link

vkcz commented Jan 24, 2021

The error unable to find ... from a @import("file_that_does_not_exist") is only produced when things from the import are used, e.g.

const mylib = @import("nonexistent");

pub fn main() void {
}

Compiling gives no errors, but if the source is changed to

const mylib = @import("nonexistent");

pub fn main() void {
    mylib.someFunc();
}

then there's the error

./src/main.zig:1:15: error: unable to find 'nonexistent'

Maybe there's a good reason for lazy evaluation in this case.
I think, however, that if there's a clear error in the code, it should be shown to the user as soon as possible.

@g-w1
Copy link
Contributor

g-w1 commented Jan 24, 2021

Everything in zig is lazy. If you make a function that makes 0 sense, but dont do anything with it, it will compile. See #2529

@SpexGuy SpexGuy added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Mar 17, 2021
@andrewrk andrewrk added this to the 0.8.0 milestone May 19, 2021
@andrewrk
Copy link
Member

As of #8554, self-hosted Zig will report file not found errors for @import expressions with non-existing files, as well as other AstGen errors, which is a pretty nice mapping to "clear error in the code".

This issue will never be addressed in stage1.

In other words, you got your wish, but you won't get the benefits until self-hosted is done.

@andrewrk andrewrk added the accepted This proposal is planned. label May 19, 2021
@andrewrk andrewrk changed the title Lazy evaluation of @import validation make @import of a non-existing file a compile error May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

4 participants