You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generic parameters void and not void clash with Error: overloaded 'test' leads to ambiguous calls
Example
type
A[T] =objectwhen T isnotvoid:
x: T
proctest[T: void](): A[T] =discardproctest[T: notvoid](): A[T] =discarddiscardtest[void]()
discardtest[float]()
Actual Output
Error: overloaded 'test' leads to ambiguous calls
Expected Output
Possible Solution
Better error message.
Additional Information
Nimskull Compiler Version 0.1.0-dev.21221 [linux: amd64]
Source hash: bd28145a33ab7540d08258b0fd306c65947c3f02
Source date: 2024-02-11
active boot switches: -d:release -d:danger⏎
The text was updated successfully, but these errors were encountered:
This is a general problem not strictly related to void. Generic parameters are ignored when comparing routine signatures for the purpose of disallowing re-definitions (refer to searchForProcAux). For example:
proctest[T: int]() =discardproctest[T: float]() =discard# error: re-definition of testproctest2[T: int](): T =discardproctest2[T: float](): T =discard# error: would lead to ambiguous calls
I think discriminating based on generic parameter constraint types is reasonable, but looking for more input on that as well. Does it make sense that we differentiate based on generic parameters, in some fashion?
Assuming the above is true, then my mind turns to more practical concerns wrt implementation. I'm not sure if the current implementation can handle the weirder cases all that well, such as those involving type operations e.g.:
proctest[T: int]() =discardproctest[T: floatorintandnotint]() =discardproctest2[T: int](): T =discardproctest2[T: floatorintandnotint](): T =discard
Perhaps we could start by swapping generic parameters for their constraints when considering signatures, that would mean test would still result in a redefinition, as no parameters would take the constraints of their respective T, and test2 would now work. At least the test scenario veers into the whole aliases vs phantom types (branding).
I would feel better about the branding situation if I could figure out how to .borrow. distinct generics. I mean, I know that's already two sides of the pentagram of pain, but still...
Specification
Generic parameters
void
andnot void
clash withError: overloaded 'test' leads to ambiguous calls
Example
Actual Output
Expected Output
Possible Solution
Better error message.
Additional Information
The text was updated successfully, but these errors were encountered: