fuzion
fuzion copied to clipboard
Failre to infer type parameters results in error messaga showing type `**error**`
This code
apply(A type,
a A,
f _ : A->String)
=>
f.call a
say <| apply _ _ 99 x->"$x*2={x*2}"
produces this message
> ./build/bin/fz ../work/webserver/content/tutorial/examples/type_parameter_example6.fz
/home/fridi/fuzion/fuzion/../work/webserver/content/tutorial/examples/type_parameter_example6.fz:7:21: error 1: Incompatible types when passing argument in a call
say <| apply _ _ 99 x->"$x*2={x*2}"
Actual type for argument #2 'f' does not match expected type.
In call to : 'apply'
expected formal type: 'Unary String A'
actual type found : '**error**'
assignable to : '**error**'
for value assigned : 'x->"$x*2={x*2}"'
To solve this, you could change the type of the target 'f' to '**error**' or convert the type of the assigned value to 'Unary String A'.
one error.
It should be possible to infer that A must be i32 and then see that the lambda actually is assignable to i32->String.