SomeRanDev / reflaxe.CPP

An alternative C++ target for Haxe that generates dependent-less, GC-less C++17 code.
MIT License
72 stars 5 forks source link

Template type argument is omitted on @:to implicit function call #20

Open fourst4r opened 1 year ago

fourst4r commented 1 year ago

Building this code

abstract Flexible(Int) {
    public function new()
        this = 1;

    @:to function toAny<T>():T
        return null;
}

function main() {
    var r:String = new Flexible();
    trace(r);
}

Will generate the following C++

std::string r = _Main::Flexible_Impl_::toAny(_Main::Flexible_Impl_::_new());

Which gives a compile error: no instance of function template "_Main::Flexible_Impl_::toAny" matches the argument list.

Putting the type explicitly in the call site fixes the error, like so:

std::string r = _Main::Flexible_Impl_::toAny<std::string>(_Main::Flexible_Impl_::_new());
fourst4r commented 1 year ago

Also note that calling toAny() explicitly: new Flexible().toAny() will produce the correct C++.