-
Notifications
You must be signed in to change notification settings - Fork 224
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
scala3: incomplete support for _
in types
#2807
Comments
also:
|
@kitbellew Thanks for collecting the info! Looks reasonable. |
I really hoped we wouldn't need to create a new dialect for each minor version of Scala 3, which will be super difficult for people to handle :/ I wonder if we could just allow each placeholder in every place, from the parser perspective this wouldn't be much of an issue: type wildcard is ? and _ Is there any specific issue that it would cause issues with? Probably the rewrite rules? 🤔 |
Also it seems the 3.2 is not bringing about the advertised changes, We can postpone the changes here. |
interesting idea... as it stands currently, our parser can tell that
|
I think it should be possible to tell from the context. Though that depends on where type lambdas can be defined 🤔 Also, how would we want to represent type lambda with placeholder? Something like:
or would we want to pack it in an additional Type.AnonymousFunction ? Anyway, we don't have to do it yet, since the migration is still far off, but it's good to start the conversation for sure. We might need to end up with additional dialects, but I don't love that idea since we would have much more of them than even in case of Scala 2. Which is why if possible I would love to see the parser try to work with all of the placeholders possible. |
something like that, yes. is there any documentation on lambdas and where there can be used? |
Very limited is here: https://docs.scala-lang.org/scala3/reference/new-types/type-lambdas.html but looking into syntax description it seems it might be used anywhere a type can be used :/ so my idea might not work unfortunately. |
@tgodzik the wildcards document mentions this: It also removes the wart that, used as a type parameter, Does that mean that we shouldn't use context-aware parsing which might result in a different interpretation? |
Yeah, accepting all possibilities will not be correct 🤔 We might need to do different dialects then after the change is introduced. |
@tgodzik , in that case, would it make sense first to introduce the if so, i can modify/relax the dialect definitions (#2809) to reflect that some things have not yet been done as mentioned in the docs. |
Sure, it makes sense to introduce the flags, but do we need the context actually if we get |
depends on how careful we want to be. since they can mean one thing only but not always acceptable, we can either reject them in inappropriate context or assume the compiler would do that... |
I think it's fine to leave it up to the compiler, we don't always reject all the problematic syntax, which is fine, we can be more inclusive. |
https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html describes this:
_
?
and_
*
?
,_
is deprecated*
?
_
,*
is deprecated?
_
In
Dialect
, we have the following today:allowQuestionMarkPlaceholder
(which is misleading since it's a wildcard but not a placeholder)allowPlusMinusUnderscoreAsPlaceholder
(which is a bit misleading since should apply to invariant placeholder types as well, not just covariant/contravariant)allowTypeParamUnderscore
(not sure if this is for a different syntax element and could remain as-is)I would suggest the following
Dialect
changes (and corresponding parser modifications):allowQuestionMarkPlaceholder
toallowQuestionMarkAsTypeWildcard
withAllowQuestionMarkPlaceholder
method for now but deprecate it (make it redirect to the newwithAllowQuestionMarkAsTypeWildcard
)allowPlusMinusUnderscoreAsPlaceholder
toallowUnderscoreAsTypePlaceholder
(to distinguish_
between wildcard in 3.1 and placeholder in 3.2)allowStarAsTypePlaceholder
allowQuestionMarkAsTypeWildcard=true
andallowUnderscoreAsTypePlaceholder=false
, although this doesn't cover the 3.2 caseThe text was updated successfully, but these errors were encountered: