-
Notifications
You must be signed in to change notification settings - Fork 1.1k
NamedTuple.From reducing on abstract types and singleton types lead to soundness holes #20517
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
Labels
area:named-tuples
Issues tied to the named tuples feature.
itype:bug
itype:soundness
Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
Comments
@sjrd do you see a way of adapting the match type machinery to scala3/compiler/src/dotty/tools/dotc/core/TypeComparer.scala Lines 3397 to 3410 in 0a3497b
|
Yes, we could/should extract |
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 2, 2024
- Move isConcrete to a new object `MatchTypes`. We should also move other MatchType-related stuff from Types and TypeComparer here. Type and TypeComparer are already unconfortably big, and MatchTypes are a coherent topic where everything should work together. - Streamline isConcrete a bit. - Re-use isConcrete for a similar test in CheckRealizable. - Re-use isConcrete for evaluating NamedTuple.From Fixes scala#20517
smarter
added a commit
that referenced
this issue
Jul 3, 2024
- Move isConcrete to a new object `MatchTypes`. We should also move other MatchType-related stuff from Types and TypeComparer here. Type and TypeComparer are already unconfortably big, and MatchTypes are a coherent topic where everything should work together. - Streamline isConcrete a bit. - Re-use isConcrete for a similar test in CheckRealizable. - Re-use isConcrete for evaluating NamedTuple.From Fixes #20517
WojciechMazur
pushed a commit
that referenced
this issue
Aug 27, 2024
- Move isConcrete to a new object `MatchTypes`. We should also move other MatchType-related stuff from Types and TypeComparer here. Type and TypeComparer are already unconfortably big, and MatchTypes are a coherent topic where everything should work together. - Streamline isConcrete a bit. - Re-use isConcrete for a similar test in CheckRealizable. - Re-use isConcrete for evaluating NamedTuple.From Fixes #20517 [Cherry-picked 532a9da]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:named-tuples
Issues tied to the named tuples feature.
itype:bug
itype:soundness
Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
Compiler version
3.5.1-RC1-bin-20240602-c6fbe6f-NIGHTLY
Minimized code
Output
Expectation
If
From
behaved like a match type then:would be a type error as
From[T]
would not reduce.And just like with match types, we can also run into troubles because of singleton types (at least those coming from dependent methods parameters as in #19746, though I had to make the test case more complex to delay reduction because
NamedTuple.From
doesn't compose withasSeenFrom
like match types do):So it seems that in general,
NamedTuple.From
and match types should share a lot more logic to prevent unsoundness.The text was updated successfully, but these errors were encountered: