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

Imprecise error message when parameter type is missing #13393

Closed
cryptocode opened this issue Nov 1, 2022 · 0 comments
Closed

Imprecise error message when parameter type is missing #13393

cryptocode opened this issue Nov 1, 2022 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@cryptocode
Copy link
Sponsor Contributor

Zig Version

0.10.0-dev.4587+710e2e7f1

Steps to Reproduce and Observed Behavior

When the type is missing:

fn func(comptime x) u64 {
    return x * 2;
}

...then the error message says the parameter name is missing, rather than the parameter type.

error: missing parameter name

Expected Behavior

Sometimes the current error message happens to make sense, i.e. when the programmer puts a type name there.

However, since type annotations require : I expected the error to say missing parameter type in this example.

Rust offers the following elaboration:

...
help: if this is a `self` type, give it a parameter name
  |
1 | fn func(self: x) -> u64 {
  |         +++++
help: if this is a parameter name, give it a type
  |
1 | fn func(x: TypeName) -> u64 {
  |          ++++++++++
help: if this is a type, explicitly ignore the parameter name
  |
1 | fn func(_: x) -> u64 {
@cryptocode cryptocode added the bug Observed behavior contradicts documented or intended behavior label Nov 1, 2022
@ifreund ifreund added error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Nov 1, 2022
@ifreund ifreund added this to the 0.10.1 milestone Nov 1, 2022
@Vexu Vexu modified the milestones: 0.10.1, 0.11.0 Nov 1, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.10.1 Jan 9, 2023
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

4 participants