Error codes · Types
PW0606
return_type
The program must hold to this: a body must produce the result type its signature declares.
A program the compiler refuses with it
module price
fn price(cents: Int) -> String !{} {
cents
}error: [PW0606] `price.price` declares its result `String` and this produces `Int`
--> price.pw:4:5
|
3 | fn price(cents: Int) -> String !{} {
| ----- `price` declares its result here
4 | cents
| ^^^^^ `price.price` declares its result `String` and this produces `Int`
|
= note: every value a body returns — its last expression, each branch of it, and each `return` — must have the result type its signature declares
= help: produce a `String` here, or change the declared resultFrom Reading a diagnostic, in Errors and diagnostics. A test holds the guide's examples to the compiler.
Reading the diagnostic
pw check prints the code in brackets, [PW0606], with the sentence above and the place in your program. Errors and diagnostics explains how to read one, and every code is listed with its rule.