Open jcward opened 6 years ago
Idea: replace monomorph inputs (just for the typeof call) with throw-away variables... So instead of typing:
tools_class.replace(subject, [foo, bar]);
Upon detecting that foo
is a monomorph, instead type:
{
var __protect_foo;
tools_class.replace(subject, [__protect_foo, b]) ;
}
Thus, foo
is not morphed and __protect_foo
is just a temporary identifier.
As shown here: http://try-haxe.mrcdk.com/#DeCd8
Calling
Context.typeof
can cause monomorphs to harden. So my strategy of "call typeof until one succeeds" is not 100% fail-safe.I could warn if any of the incoming params are monomorphs (though I think the behavior could be deeper than the params themselves?)