-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
std.json: fix compile error for comptime fields #10849
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
std.json: fix compile error for comptime fields #10849
Conversation
I don't understand why this would be needed..... is this working around a compiler bug? |
I don't know what the expected behavior is when you pass a The stdlib tests for this file are currently failing because of this issue. Is that not what you see if you run them? |
Here's what I get over here on master
|
Please be descriptive on what semantics your code change has. Before the change the compiler (I do assume stage1) crashed on the comptime field.
Which test? I dont see any disabled one inside json.zig and json/test.zig Finally and most important: Can you provide a use case that justify this hack to derive behavior from a opaque pointer meant to only be used on the external interfacing code ? |
tests currently pass for me; and on every CI run for the repository. |
Prior to the change in which anytype fields were removed from the language, this line already used the default value. This change attempts to restore that behavior, by passing the default value to parsesTo, which is a function that takes a type, a value of that type, and some tokens, and checks whether the tokens parse to the value. The intent of this line is to check that the value of the field in the json is equal to the value of the comptime field. If there is some philosophical objection to the idea of accessing the default value (which is where the value of the comptime field is stored) ever for any reason, I guess we will have to give up on the idea of having a generic json parser that can verify that values in json objects correspond to comptime fields. In that case, I can submit a different patch that completely removes the feature. I would also need to remove the current feature where the json parser is willing to parse inputs that have missing fields and use the default value for those fields, which involves this existing code:
It's not disabled. I posted the output and the command used to generate the output in the comment immediately preceding yours.
The above is the failure I observe when I run precisely these commands on my M1 mac, starting with no zig2 folder:
I haven't succeeded in building llvm 13 on linux on x64, but I am also able to reproduce this test failure on linux on x64 by running the test using a zig binary obtained from snap against a fresh clone of the repository. the zig binary obtained from snap reports its version as 0.10.0-dev.662+e139c41fd. That is, after acquiring the zig from snap, I can run these commands on linux on x64 to also produce the output I posted above:
I am attempting to follow the instructions given at https://github.com/ziglang/zig/wiki/Building-Zig-From-Source and https://github.com/ziglang/zig/blob/master/CONTRIBUTING.md about building zig (in the case of the M1 mac) and running stdlib tests. Have I done so incorrectly? |
Ah it seems I tested against non-latest zig. updating to master I indeed see the same failure.
Ah ha! I now understand where the change comes from. |
This is covered by an existing test which was already failing.
Only about half of the tests in std were actually being run (918 vs 2144).
c12ffb0
to
8937f18
Compare
I wonder if this also needs an |
This is covered by an existing test which was already failing.