-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Type named $
is replaced by empty string in error messages
#15381
Comments
Names with |
We could still try to print the |
I've tried to debug this. Trailing override def nameString(name: Name): String =
def strippedName = if printDebug then name else name.stripModuleClassSuffix
... I understand that this is desired behaviour, because we want do display compiler-generated names without trailing dollars. I don't see any easy way to distinguish between user provided names and those generated by compiler. Potentially, we could add field to |
Why then allow |
|
This problem exists with any name ending with case class T$[A](value: A)
def f(x: Int): Unit = {}
@main def main = f(T$(3)) Output:
|
There are perverse usages of It might be useful to add a FAQ about these edges. |
case class T$[A](value: A) Will not compile correctly, the class T$ will conflict with the class of the companion object with the same name. One will override the other. This behavior is consistent with the undefined behavior of names using |
The best thing we could do is to identify names containing |
I don't know about the best thing. This does the right thing for innocent I probably would not write |
So, I do have a real world example that is used a fair amount, albeit not a
JVM one: the jquery-facade library that I wrote for the Scala.js ecosystem:
https://github.com/jducoeur/jquery-facade
That uses '$' quite heavily, because it is trying to closely mimic the
underlying jQuery library that it wraps around - this allows us to leverage
the existing documentation and ecosystem with as little surprise as
possible. (jQuery used to be perhaps the most important JavaScript library;
it has lost a lot of ground, but is still moderately popular.)
…On Wed, Jul 6, 2022, 1:11 AM som-snytt ***@***.***> wrote:
I don't know about the best thing.
This does the right thing for innocent $: #15597
<#15597>
I probably would not write object syntax { object $ }.
—
Reply to this email directly, view it on GitHub
<#15381 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQVNYKN552D2KHDAOXAGTDVSUIRHANCNFSM5X5RGUCA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The authors or maintainers of jQuery wrapper library have been told many years ago that their use of the |
A backquoted identifier is usually just an identifier. The famous exception is it's not a pattern varid. The recent exception is it's not a unary prefix operator. Backquotes also change syntax for leading infix operators: instead of an exclusion, it lets a non-symbolic identifier "opt in" as leading infix. Backquotes don't have uniform semantics, but are more like variance: add backquotes until it compiles. If the language had adopted guillemets, there would be more quotes to try before giving up. Of course, autocorrect just changed guillemets to guillemots, which is the bird even though mot means word. Worth acknowledging that the Mets baseball team is having a pretty good year. |
The issue about accessing Scala
|
It appears to be working : case class $[A](value: A)
def f(x: Int): Unit = {}
val x = f($(3)) Error output : -- [E007] Type Mismatch Error: /home/billal/Projects/foss/dotty_playground/15381/15381.scala:5:11
5 |val x = f($(3))
| ^^^^
| Found: $[Int]
| Required: Int
|
| longer explanation available when compiling with `-explain`
See test added by the following commit : b5203de |
Found and closed during the Scala spree at ScalaIO 2022 - thanks @Billal-B for spotting! |
My previous comment may have been why I thought it might not be closed #15381 (comment) |
Compiler version
3.1.3-RC2
Minimized code
Output
Notice the missing
$
.Expectation
The text was updated successfully, but these errors were encountered: