-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Code does not compile when using T as v
instead of using v: T
#23272
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
Comments
Comparing the unexpected vs expected, the "using as" is in the wrong place for desugared map.
|
Does this mean this is a compiler bug, a spec bug (is the desugaring of context bounds for extensions even specced?), or is my code wrong? |
That is a good question. It is specified here but doesn't mention collective extensions. Either it's obvious that "end" means the end of the "collective" signature, or it's obvious that extensions are regular methods and "end" means the regular end of the signature. An ugly workaround is
My guess would be that this is "as specified", since similar requests to make collective extension do more work, such as introducing a scope, were rejected. The problem with the code is that Possibly one could concoct a more compelling use case to change desugaring of context bounds. I just ran out of steam (or coffee), so I won't attempt that right now. My intuition was the same as yours (the first obvious interpretation above) but it may be easier to reason about the current behavior (the second obvious interpretation). |
Worth adding, maybe there was previously a strong reason to collect all implicit parameters at the very end of a signature, and to avoid interleaving, for reasons of usability. I don't know if that is currently the case. |
What surprises me: when
is tried unsuccessfully, why the search stops here and the
better? |
I think the enigmatic
means that it hasn't chosen yet. The doc says first it tries Apparently, "constructed" means that
To answer the question, having the implicit param list after the leading explicit param lets it "fail to construct" (when the implicit is missing) and then try the second step, which is extensions from implicit scope and also implicit conversions. The wrapper for Array is still an "old-style" implicit conversion. |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.6.0, 3.7.0, 3.7.1-RC2
Minimized code
Output
Expectation
The code should compile. The same code compiles when using
extension [V](lhs: V)(using v: Vectoric[V])
Maybe my expectation is wrong and the two forms are not equivalent, in which can I would be glad if anyone can explain the difference.
Note
There is no error when I remove the
map
method fromVectoricOps
extension.The same error is produced when using:
The text was updated successfully, but these errors were encountered: