fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Free types behave slightly differently with respect to feature argument counts

Open fridis opened this issue 1 year ago • 1 comments

This example defines two features x using an explicit type parameter and two features y using a free type parameter. Both declarations should be equivalent:

x(T type, v T)    => say "x1 $T $v"
x(T type, v, w T) => say "x2 $T $v $w"

x i32 42

y(v T)    => say "y1 $T $v"
y(v, w T) => say "y2 $T $v $w"

y i32 42   # -- causes unjustified error!

however, the second one causes an error when trying to call y(T,v) with an explicit type parameter

 > ./build/bin/fz test_call3.fz 

/home/fridi/fuzion/work/test_call3.fz:9:3: error 1: Different count of arguments needed when calling feature
y i32 42   # -- causes unjustified error!

Feature not found: 'i32' (no arguments)
Target feature: 'universe'
In call: 'i32'
To solve this, you might change the actual number of arguments to match the feature 'i32' (one argument) at $MODULE/i32.fz:28:8:
public i32(public val i32) : num.wrap_around, has_interval is


one error.

apparently, the call y i32 42 ends up calling y(T,v,w) and i32 is treated as a value and not as a type.

fridis avatar Aug 19 '24 07:08 fridis

duplicate of #1781

simonvonhackewitz avatar Mar 12 '25 12:03 simonvonhackewitz