-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle NoType in TypeComparer.disjointnessBoundary #21520
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Error: tests/neg/i20265-1.scala:4:6 --------------------------------------------------------------------------------- | ||
4 | def apply(args: Tuple.Map[m.MirroredElemTypes, Expr]): Expr[T] = ??? // error | ||
| ^ | ||
| non-private method apply in trait Ops refers to private given instance m | ||
| in its type signature (args: Tuple.Map[Ops.this.m.MirroredElemTypes, Expr]): Expr[T] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
trait Expr[T] | ||
|
||
trait Ops[T](using m: scala.deriving.Mirror.ProductOf[T]) { | ||
def apply(args: Tuple.Map[m.MirroredElemTypes, Expr]): Expr[T] = ??? // error | ||
} | ||
|
||
case class P(a: Int) | ||
object P extends Ops[P] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- [E172] Type Error: tests/neg/i20265.scala:22:95 --------------------------------------------------------------------- | ||
22 | println(summon[((String --> Unit) * (String --> Unit)) =:= Hinze[(String + String) --> Unit]]) // error | ||
| ^ | ||
| Cannot prove that (String --> Unit) * (String --> Unit) =:= Hinze[String + String --> Unit]. | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Hinze[String + String --> Unit] | ||
| failed since selector (String + String --> Unit)#unfix | ||
| does not match case k1 + k2 --> v => Hinze[k1 --> v] * Hinze[k2 --> v] | ||
| and cannot be shown to be disjoint from it either. | ||
| Therefore, reduction cannot advance to the remaining case | ||
| | ||
| case k1 * k2 --> v => k1 --> Hinze[k2 --> v] | ||
-- [E172] Type Error: tests/neg/i20265.scala:23:66 --------------------------------------------------------------------- | ||
23 | println(summon[String =:= Hinze[Fix[Lambda[String]#L] --> Unit]]) // error | ||
| ^ | ||
| Cannot prove that String =:= Hinze[Fix[[X] =>> String + String * X + X * X] --> Unit]. | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Hinze[Fix[[X] =>> String + String * X + X * X] --> Unit] | ||
| failed since selector (Fix[[X] =>> String + String * X + X * X] --> Unit)#unfix | ||
| does not match case k1 + k2 --> v => Hinze[k1 --> v] * Hinze[k2 --> v] | ||
| and cannot be shown to be disjoint from it either. | ||
| Therefore, reduction cannot advance to the remaining case | ||
| | ||
| case k1 * k2 --> v => k1 --> Hinze[k2 --> v] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//> using options -source:3.3 | ||
|
||
trait Poly | ||
trait -->[X, Y] extends Poly | ||
trait +[X, Y] extends Poly | ||
trait *[X, Y] extends Poly | ||
|
||
type Hinze[X <: Fix[?]] = X#unfix match | ||
case (k1 + k2) --> v => Hinze[(k1 --> v)] * Hinze[(k2 --> v)] | ||
case (k1 * k2) --> v => k1 --> Hinze[(k2 --> v)] | ||
|
||
trait Lambda[V]: | ||
type Abs[X] = V * X | ||
type App[X] = X * X | ||
type L[X] = V + Abs[X] + App[X] | ||
|
||
trait Fix[F[X]]: | ||
type unfix = F[Fix[F]] | ||
|
||
@main | ||
def m = | ||
println(summon[((String --> Unit) * (String --> Unit)) =:= Hinze[(String + String) --> Unit]]) // error | ||
println(summon[String =:= Hinze[Fix[Lambda[String]#L] --> Unit]]) // error |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defn.NothingType
is another alternative, but usingAnyType
gives error messages similar to what we get from Scala 3.3.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defn.AnyType
is definitely better.NoType
shouldn't be here. At best we have to treat it likeErrorType
just above.Perhaps add an assertion that we only get here under
-source 3.3
? LikeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the example I added to #20265
hits this crash without specifying
-source 3.3
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it should also be added as a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjrd I've added it as
tests/neg/i20265-1.scala