This commit is a potentially breaking change, but the problem was that
linalg was relying on a previous bug in the compiler, which was fixed
in the concepts branch.
With the old disambiguation rules, generic procs like:
proc \`==\`[T](lhs, rhs: T)
and
proc \`==\`(lhs, rhs: Matrix32|Matrix64)
.. were considered equal, even though it's obvious that the second one
should be preferred. We never noticed this, because there was a bug in
sigmatch incorrectly counting one of the params of the second proc as
a non-generic match, thus giving it an edge.
This commit gives some preference to tyOr and tyAnd during the complex
disambiguation, which may affect overload resolution in other cases.
I see this only as a temporary solution. With my upcoming work on
concept refinement, I plan to provide an experimental implementation
of alaternative C++-like rules for determining which proc is more specific.
We can then discuss our strategy for dealing with such a breaking change.
A more efficient implementation is possible by restoring the old
lifting ot tyGenericInvocation to tyGenericInst in liftTypeParam,
but this fix will suffice for now.
fixes#5087fixes#5602fixes#5641fixes#5570
Fixed the dot operator when used within return types (see tgenericdotrettype)
Fixed the matching of generic concepts aliases used with the implicit generics style
* Why is tyInferred needed?
The bindings in TCandidate are capable of inferring types within a single
call expression. In concepts, we need to infer types in the same way, but
across the whole body of the concept.
Previously, once a concept type param was inferred, it was destructively
mutated using t.assignType, but this proved to be problematic in the presence
of overloads, because the bindings established while a non-matching overload
is tested must be reverted/forgotten. tyInferred offers a non-destructive way to
keep track of the inference progress.
While introducing new types usually requires a lot of code paths in the compiler
to updated, currently tyInferred is only a short-lived type within the concept body
pass and it's unlikely to introduce breakage elsewhere in the compiler.
This commit returns to a bit less strict checking of the number
of macro arguments, because some old immediate macros rely on a
behavior where even the arity of the macro is not being checked.
It may be better if such macros are just declared to use varargs[expr],
but this remains for another day.