jakt
jakt copied to clipboard
Return type not correctly inferred when returning newly constructed instance
To reproduce:
class C {
public function creat() throws {
let s = true
return C()
}
}
function main() {
println("{}", C::creat())
}
When compiling, the following error from the C++ is produced:
error: no viable conversion from returned value of type 'Jakt::NonnullRefPtr<Jakt::C>' to function return type 'ErrorOr<void>'
return (TRY((C::create())));
^~~~~~~~~~~~~~~~~~~~
Workaround: The error goes away and the main()
function works are expected if the creat()
function is changed to explicitly state the return type:
public function creat() throws -> C {
...
}
Problem also goes away if the assignment in the function body is removed. See #1093.
This is basically fixed as we no longer infer the return type of function blocks