fuzion
fuzion copied to clipboard
Used abstract feature is not implemented, but I think it is?
This example:
ex =>
seq(T type) ref is
str(U type) ref : seq U is
a U is abstract
b(V type, c V) str V is
ref : str V
redef a V is
c
say ((str string).b "hello").a
yields:
/home/sam/playground/test.fz:5:3: error 1: Used abstract feature a is not implemented
str(U type) ref : seq U is
--^
Feature 'ex.str' instantiated at /home/sam/playground/test.fz:14:9:
s := (str string)
--------^
inherits or declares abstract feature 'ex.str.a' declared at /home/sam/playground/test.fz:7:5:
a U is abstract
----^
which is called at /home/sam/playground/test.fz:15:20:
say s.b("hello").a
-------------------^
without providing an implementation
one error.
Updated the example
ex =>
seq(T type) ref is
str(U type) ref : seq U is
a U is abstract
b(V type, c V) str V is
ref : str V
redef a V is
c
say ((str String).b "hello").a
This shows two errors now
● fridi@zen:~/fuzion/work 11:34:06 > PRECONDITIONS=true POSTCONDITIONS=true ./build/bin/fz ex373.fz
/home/fridi/fuzion/work/ex373.fz:9:5: error 1: Recursive value type is not allowed
b(V type, c V) str V is
----^
Value type (ex.str String).b String equals type of outer feature.
The chain of outer types that lead to this recursion is:
1: (ex.str String).b String at /home/fridi/fuzion/work/ex373.fz:9:5:
b(V type, c V) str V is
----^
2: ((ex.str String).b String).#anonymous0 at /home/fridi/fuzion/work/ex373.fz:10:7:
ref : str V
------^
3: (ex.str String).b String at /home/fridi/fuzion/work/ex373.fz:9:5:
b(V type, c V) str V is
----^
To solve this, you could add a 'ref' after the arguments list at /home/fridi/fuzion/work/ex373.fz:9:5:
b(V type, c V) str V is
----^
/home/fridi/fuzion/work/ex373.fz:5:3: error 2: Used abstract feature 'ex.str.a' is not implemented by 'ex.str'
str(U type) ref : seq U is
--^
Feature 'ex.str' instantiated at /home/fridi/fuzion/work/ex373.fz:14:9:
say ((str String).b "hello").a
--------^
inherits or declares abstract feature 'ex.str.a' declared at /home/fridi/fuzion/work/ex373.fz:7:5:
a U is abstract
----^
which is called at /home/fridi/fuzion/work/ex373.fz:14:32:
say ((str String).b "hello").a
-------------------------------^
without providing an implementation
2 errors.
The problems with these two errors
- the first one is maybe justified, but confusing: The anonymous inner feature
ref: stris the problem, its outer feature isb, which itself is defined instr, so we could callbwithin the anonymous inner feature causing and endless chain nestedbs (but this might be ok since the inner feature is aref). - the second error is obviously wrong.
update example:
ex =>
str(U type) ref is
a U => abstract
b(V type, c V) str V =>
ref : str V
redef a V =>
c
say ((str String).b "hello").a