MVCoconut / coconut.ui

Wow, such reactive view! Much awesome!
The Unlicense
89 stars 9 forks source link

Function with optional arguments #68

Closed kevinresol closed 4 years ago

kevinresol commented 4 years ago
class Main{
    static function main() {
        var f:(value:String, ?event:Int)->Void = null;
        coconut.Ui.hxx('<Foo f=${f}/>');
    }
}

class Foo extends coconut.vdom.View {
    @:attr var f:(value:String, ?event:Int)->Void;
    function render() return null;
}
src/Main.hx:4: characters 20-23 : error: Optional attribute of parameter  differs
src/Main.hx:4: characters 20-23 :  have: { f: coconut.data.Value<(..., Dynamic) -> ...> }
src/Main.hx:4: characters 20-23 :  want: { f: coconut.data.Value<(..., Dynamic) -> ...> }
src/Main.hx:4: characters 20-23 : For function argument 'attributes'

There are a few quirks here:

kevinresol commented 4 years ago

Tried to print getExpectedType for the attr:

TFun([{name: , t: TInst(String,[]), opt: false},{name: , t: TAbstract(Null,[TAbstract(<...>,<...>)]), opt: false}],TAbstract(Void,[]))

so the second arg is Null<Int> but opt:false

back2dos commented 4 years ago

Fixed via tink_macro@0.19.3