compile errors
Message-Id: https://www.5snb.club/w/compile-errors/
Linked-From: wiki.
compile errors are the only form of language tutorial that your users will be exposed to, so you should probably make sure they’re good and helpful.
this includes good parser error recovery and good suggestions for when you fuck up
see: rust converting printf
syntax into print!
(playground link):
fn main() {
print!("%d %ull %.2f\n", 42, 2, 1.0);
}
error: multiple unused formatting arguments
--> src/main.rs:2:30
|
2 | print!("%d %ull %.2f\n", 42, 2, 1.0);
| ---------------- ^^ ^ ^^^ argument never used
| | | |
| | | argument never used
| | argument never used
| multiple missing formatting specifiers
|
= note: printf formatting is not supported; see the documentation for `std::fmt`
help: format specifiers use curly braces
|
2 | print!("{} {}ll {:.2}\n", 42, 2, 1.0);
| ~~ ~~ ~~~~~
you can check out the tests for that. Apparently shell formatting is supported too? someone had fun writing this.
The error for “putting a comma in a list” in nix… sucks?
# nix eval --expr "[1, 2]"
error: syntax error, expecting ']'
at «string»:1:3:
1| [1, 2]
| ^
would be nicer if it said something akin to:
note: lists in nix are delimited by spaces, not commas, see https://nix.dev/manual/nix/2.24/language/syntax#list-literal
That and
# nix eval --expr "[builtins.head [1 2] 3]"
[ «primop head» [ 1 2 ] 3 ]
is probably not what you wanted either.
The correct thing is to surround the function and its arguments in parenthesis, making it
# nix eval --expr "[(builtins.head [1 2]) 3]"
[ 1 3 ]