Open fridis opened 1 year ago
updated the example to work with current Fuzion:
fib_zip is
listX(A type, h A, t ()->list A) list A is nil
infix :: (A type, val A, l ()->list A) => listX val l
fibs => ()->(0 :: ()->fibs.zip 1:()->fibs a,b->a+b)
fib(n i32) => (fibs().drop n).head
results in
> ./build/bin/fz ex_929.fz
/home/fridi/fuzion/work/ex_929.fz:9:18: error 1: Illegal forward or cyclic type inference
fib(n i32) => (fibs().drop n).head
-----------------^
The definition of a field using ':=', or of a feature or function
using '=>' must not create cyclic type dependencies.
Referenced feature: 'fib_zip.fibs' at /home/fridi/fuzion/work/ex_929.fz:8:3:
fibs => ()->(0 :: ()->fibs.zip 1:()->fibs a,b->a+b)
--^
one error.
I think one possible reason this may happen is because fields types are inferred via outer. If outer is not inferred yet field can not be inferred leading to this error.
This example results in an error referencing the call at line 8, which is not part of the cycle