Skip to content

@implicitAmbiguous is ignored on third ambiguous implicit #10739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Blaisorblade opened this issue Feb 20, 2018 · 0 comments
Open

@implicitAmbiguous is ignored on third ambiguous implicit #10739

Blaisorblade opened this issue Feb 20, 2018 · 0 comments
Labels
Milestone

Comments

@Blaisorblade
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants