fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

lambda targets that are not `universe` do not work inside their outer features

Open fridis opened this issue 2 months ago • 0 comments

lambdas targets that are defined inside the features they are used in currently do not work (since the outer type is xyz.this and the lambda will be created in xyz.fun#123).

Try this:

o is
  F ref is
    c(a i32) i32 : fuzion.lambda_target => abstract

  _ F := x->x+1   # causes error!!!

_ o.F := x->x+1   # works fine

which produces an error for the use of F as a target for a lambda within o:

 > ./build/bin/fz test_lambda.fz

/home/fridi/fuzion/fuzion/test_lambda.fz:5:3: error 1: Incompatible types in assignment
  _ F := x->x+1   # causes error!!!

assignment to field : 'o._'
expected formal type: 'o.this.F'
actual type found   : 'o.this.λ'
assignable to       : 'Any',
                      'o.F',
                      'o.this.λ'
for value assigned  : 'x->x+1'
To solve this, you could change the type of the target 'o._' to 'o.this.λ' or convert the type of the assigned value to 'o.this.F'.

one error.

fridis avatar Oct 06 '25 10:10 fridis