zig
zig copied to clipboard
Imprecise error message when parameter type is missing
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 {