fuzion
fuzion copied to clipboard
Partial application used with partial type parameters results in confusing error message
Feature ID in the following code has two arguments T and d, one type parameter and a value argument. Partial application works well when both are omitted:
> ./build/bin/fz -e "ID(d T) => {d}; say ([true, false & true, true] ∀ (ID))"
false
but giving only the type parameter results in this confusing error
> ./build/bin/fz -e "ID(d T) => {d}; say ([true, false & true, true] ∀ (ID bool))"
command line:1:55: error 1: Cannot call choice feature
ID(d T) => {d}; say ([true, false & true, true] ∀ (ID bool))
------------------------------------------------------^^^^
A choice feature is only used as a type, values are created by assignments only.
Choice feature that is called: 'bool'
Declared at $MODULE/bool.fz:39:8:
public bool : choice FALSE TRUE, property.equatable is
-------^
one error.
The reason is that ID bool is treated as ID XXX bool where XXX is an inferred type parameter. Producing an error here is ok since permitting this code would likely result in more confusing ambiguities, but the error could maybe be better.
I do not see that #5035 fixed this issue since it only adds a test for the first case, which always worked... :-)