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
It appears that if you have three ambiguous implicits, and @implicitAmbiguous is on the "third", the custom error message will not be noticed. @Jasper-M suggested a documentation fix, because of the runtime complexity of a proper fix.
That's because (apparently) the compiler reports an implicit error as soon as it finds two ambiguous implicits, even though there might be more. Since it doesn't find additional ambiguous implicits, it can't check if they're annotated. And it's not obvious if searching for additional implicits is acceptable performance-wise, since IIUC ambiguous implicit errors might trigger backtracking.
It appears that if you have three ambiguous implicits, and
@implicitAmbiguous
is on the "third", the custom error message will not be noticed. @Jasper-M suggested a documentation fix, because of the runtime complexity of a proper fix.That's because (apparently) the compiler reports an implicit error as soon as it finds two ambiguous implicits, even though there might be more. Since it doesn't find additional ambiguous implicits, it can't check if they're annotated. And it's not obvious if searching for additional implicits is acceptable performance-wise, since IIUC ambiguous implicit errors might trigger backtracking.
I've noticed this for the new Dotty implementation, and @Jasper-M mentioned Scalac seems to have the same problem. scala/scala3#4007 (comment).
That only two implicits are considered at reporting time is visible for Scalac in scala/scala#4673.
That Dotty ignores further ambiguous implicits is most visible in scala/scala3@ea640a3#diff-dd16b03dc9d12f6fae5536ba8eb8dc8eR236, but I haven't checked in Scalac or in the latest Dotty implementation.
Sorry for not checking further, please let me know if this ticket is premature.
The text was updated successfully, but these errors were encountered: