The type checker is only supposed to say "impossible to determine the type" if something remains polymorphic, i.e. if one of the types can be chosen arbitrarily and still solve the system.
That would have been the case it you had written:
But when instantiating the class with integer, only integer will solve the system. So this is a bug.
The situation will however not happen often, because normally
you will use the value (rather than just throwing it away like here), and then the usage will typically fix the type:
Code: Select all
clauses
run() :-
Factory = myObj::new,
use(Factory).
Should nothing fix the type, you can fix it explicitly using
hasDomain:
Code: Select all
clauses
run() :-
hasDomain(core::function{integer}, Factory),
Factory = myObj::new,
use(Factory).
Or using the new (i.e. vip 7.5) function form of hasDomain:
Code: Select all
clauses
run() :-
Factory = hasDomain(core::function{integer}, myObj::new),
use(Factory).
We will of course address the bug.