Skip to content

Fix a compiler assertion crash #16291

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 1 commit into from
Nov 25, 2022
Merged

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Nov 7, 2022

No description provided.

@dwijnand dwijnand marked this pull request as draft November 7, 2022 16:22
@dwijnand dwijnand marked this pull request as ready for review November 8, 2022 08:35
@@ -2633,7 +2633,8 @@ object Types {
}
}
if (prefix.isInstanceOf[WildcardType]) WildcardType
else withPrefix(prefix)
else if prefix.isValueTypeOrWildcard || (prefix eq NoPrefix) then withPrefix(prefix)
else typer.ErrorReporting.errorType(i"Cannot ($this).deriveSelect($prefix)", ctx.tree)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message shows up if I change mkArray[Array] to val x = mkArray[Array] so a more user-friendly message would be nicer.

I was trying to see if we could catch the problem earlier but it's a bit tricky. The problem is that when the prefix is erroneous we still create dummy denotations in findMember: https://github.com/lampepfl/dotty/blob/970d1191ae61dbcc2c10f55ee749c946e35d57db/compiler/src/dotty/tools/dotc/core/Types.scala#L725-L726
If we just drop this case and return a NoDenotation then we avoid these complications, but that could maybe lose information.

Otherwise we could try to handle these error denotations better, but it's tricky because newErrorSymbol actually wraps the ErrorType in a TypeAlias when the member is a type, and Type#isError doesn't check that.

@dwijnand dwijnand assigned smarter and unassigned prolativ Nov 23, 2022
@dwijnand dwijnand requested a review from smarter November 23, 2022 08:53
@dwijnand dwijnand merged commit ce38da4 into scala:main Nov 25, 2022
@dwijnand dwijnand deleted the assertion-crash branch November 25, 2022 11:27
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants