fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Poor error message in case of incompatible `e.this` argument in call

Open fridis opened this issue 1 year ago • 0 comments

This

e : effect is

  stop => e.type.abort e.this

results in the following error

 > ../clean/fuzion/build/bin/fz test_e_this.fz

/home/fridi/fuzion/work/test_e_this.fz:3:24: error 1: Incompatible types when passing argument in a call
  stop => e.type.abort e.this

Actual type for argument #1 'e' does not match expected type.
In call to          : 'effect.type.precall abort'
expected formal type: 'e'
actual type found   : 'e.this'
assignable to       : 'ref e'
for value assigned  : 'e.this'
To solve this you could:
  • make  'e' a reference by adding the 'ref' keyword, so all its heirs can be used in place of it,
  • change the type of the target 'e' to 'e.this', or
  • convert the type of the assigned value to 'e'.

one error.

There are a number of issues with this this:

  • the error does not suggest the best solution, which would be to add fixed before stop
  • the call to mentions effect.type.precall abort, which is just the name of the result of the precondition syntax sugar, should just be effect.type.abort
  • assignable to says ref e, which is syntax that is no longer supported, value e.this is only assignable to type e.this
  • what does change the type of the target 'e' to 'e.this' mean?

fridis avatar Sep 12 '24 16:09 fridis