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

Suggest .{} syntax when accidentally using {} #22402

Open
vegerot opened this issue Jan 3, 2025 · 4 comments
Open

Suggest .{} syntax when accidentally using {} #22402

vegerot opened this issue Jan 3, 2025 · 4 comments
Labels
error message This issue points out an error message that is unhelpful and should be improved.

Comments

@vegerot
Copy link

vegerot commented Jan 3, 2025

Zig Version

0.13.0

Steps to Reproduce and Observed Output

Correct code:

var position = raylib.Vector2{.x = 0, .y = 0};
// ...
position = .{.x = 42, .y = 69};

Wrong code

var position = raylib.Vector2{.x = 0, .y = 0};
// ...
position = {.x = 42, .y = 69};

Error message:
image

me/game.zig:361:98: error: expected ';' after statement
                        {.x = 42, .y = 69}

Expected Output

me/game.zig:42:69: error: start inferred structs with `.{`
                            .{.x = 42, .y = 69}
@vegerot vegerot added the error message This issue points out an error message that is unhelpful and should be improved. label Jan 3, 2025
@vegerot
Copy link
Author

vegerot commented Jan 3, 2025

As someone new to Zig, this keeps tripping me up, and it takes me a few seconds to realize the actual bug

@rohlem
Copy link
Contributor

rohlem commented Jan 4, 2025

sort of a duplicate / related to #16591 (that's the first one I found, there may yet be others)

@oneslash
Copy link

oneslash commented Jan 7, 2025

I am not sure but shouldn't be this reported in ZLS repository?
https://github.com/zigtools/zls

@rohlem
Copy link
Contributor

rohlem commented Jan 7, 2025

shouldn't be this reported in ZLS repository?

If you want to suggest an improvement to ZLS, then sure.
The message error: expected ';' after statement is the compile error produced by the Zig compiler though.
I guess in the screenshot ZLS is forwarding it to the user.
(Or maybe they're generating the same message internally? But when compiling the source code you receive the same message from the zig compiler directly.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message This issue points out an error message that is unhelpful and should be improved.
Projects
None yet
Development

No branches or pull requests

3 participants