-
Notifications
You must be signed in to change notification settings - Fork 1
TYP004
ricardoboss edited this page Sep 13, 2023
·
1 revision
A function returned an unexpected result type. This can happen if a function was called without handling its result (hence a void result was expected), or when trying to save the result of a function that does not return anything:
Example:
function add = (number a, number b) {
return a + b
}
add(1, 2)
or:
function printMessage = (string message) {
print("msg: ", message)
}
string result = printMessage("Hello, World!")
Ensure the function you are trying to call returns the type you are expecting.
Example:
function add = (number a, number b) {
return a + b
}
- add(1, 2)
+ number result = add(1, 2)
or alternatively, discard the result explicitly:
function add = (number a, number b) {
return a + b
}
- add(1, 2)
+ _ = add(1, 2)
When handling void functions, ensure you do not try to save their result:
function printMessage = (string message) {
print("msg: ", message)
}
- string result = printMessage("Hello, World!")
+ printMessage("Hello, World!")
© 2023 Ricardo Boss • Licensed under MIT • Want to update this page? Edit it on GitHub and submit a pull request!