-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
support top level fields #2022
Comments
This seems to already work in stage 1: a: u8,
test "" {
var s = @This(){ .a = 22 };
@import("std").testing.expectEqual(u8(22), s.a);
} When I did the grammar rework I allowed fields at top level in the syntax, and now that files are empty structs, it seems to work it just haven't been tested. To close this, we probably need:
|
ah! I got tricked by vim integration with |
Also just to repeat this here: The "index.zig" convention is deprecated. The new pattern is the one set by
|
Also, files cannot be generic so the redundant import problem is only solved for none generic structs. |
I was in the mood for a little bit of bikeshedding, so I refactored my project to use toplevel fields wherever possible. No issues so far on zig 0.6.0. Repository here for the curious: https://github.com/ifreund/river. |
Now that #1047 is done, and every file is implicitly an empty struct, we could allow fields at the top level. This would solve the redundant import problem:
zig/std/index.zig
Lines 3 to 10 in 96164ce
Syntactically it looks a bit odd, but semantically it makes sense.
The text was updated successfully, but these errors were encountered: