fuzion
fuzion copied to clipboard
ambiguous lambda target should cause nicer error
Try this code that has two ambiguous lambda targets c and c.
F ref is
c(a i32) i32 : fuzion.lambda_target => abstract
d(a i32) i32 : fuzion.lambda_target => abstract
_ F := x->x+1
It produces an error:
> ./build/bin/fz test_lambda.fz
/home/fridi/fuzion/fuzion/test_lambda.fz:5:8: error 1: Target type of a lambda expression must be a plain type whose feature inherits 'fuzion.lambda_target', e.g., 'Function'.
_ F := x->x+1
A lambda expression can only be used if assigned to a field or argument whose type contains an abstract lambda target feature
with argument count of the lambda expression equal to the effective argument count of the lambda target.
Target type: 'F'
To solve this, assign the lambda expression to a type that is a lambda target, e.g., 'f (i32, i32) -> bool := x, y -> x > y'.
one error.
But the error could be better referring to the ambiguity between c and d.