ponyc
ponyc copied to clipboard
Confusing error message when method only includes variable declarations
ponyc version:
0.24.0 [release]
compiled with: llvm 3.9.1 -- gcc (GCC) 7.3.0
Defaults: pic=false ssl=openssl_0.9.0
source:
actor Main
new create(env:Env) =>
confusing_error_msg()
fun confusing_error_msg(): String =>
var s = "A string."
// Forget to return a string
//s
compiler output:
0.24.0 [release]
compiled with: llvm 3.9.1 -- cc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
Defaults: pic=false ssl=openssl_0.9.0
Error:
main.pony:26:9: the left side is undefined but its value is used
var s = "A string."
^
Error:
main.pony:26:11: left side must be something that can be assigned to
var s = "A string."
^
Furthermore, changing the return type of confusing_error_msg to None results in a successful build, without any error output mentioning unused variables. I remember receiving errors regarding unused declarations previously, and am unsure if they are still a compilation error.
I think this is more generally a problem with the error message. At the very least maybe we could have a hint that says something about "destructive read" to give people a place to look? I don't necessarily think we need a specific error message for this situation (where the code indicates that the result of an initial destructive read should be returned by the function). I think the second error is also confusing (or even inaccurate) and should probably not appear.
I'd like to tackle this issue.
@adri326 have at it!