Skip to content
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

Do not crash when typing a closure with unknown type, since it can occur for erroneous input #21178

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

KacperFKorban
Copy link
Member

closes #20511

@KacperFKorban KacperFKorban marked this pull request as ready for review July 16, 2024 10:34
Comment on lines -1980 to -1981
if !tp.isErroneous then
throw new java.lang.Error(i"internal error: closing over non-method $tp, pos = ${tree.span}")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the correct fix. IMHO, for this kind of errors, we shouldn't run the typer in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm, I think that this might actually be the correct fix. I even tried short-circuiting before typing ahead in Namer, but the presentation compiler leverages this for completions.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, but we should open an issue for a better error messages !

tests/neg/i20511.scala Outdated Show resolved Hide resolved
@KacperFKorban KacperFKorban marked this pull request as draft October 18, 2024 12:31
@KacperFKorban KacperFKorban marked this pull request as ready for review November 18, 2024 21:19
Comment on lines -1980 to -1981
if !tp.isErroneous then
throw new java.lang.Error(i"internal error: closing over non-method $tp, pos = ${tree.span}")
Copy link
Member

Choose a reason for hiding this comment

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

Alright, but we should open an issue for a better error messages !

@hamzaremmal hamzaremmal merged commit 3a5e137 into scala:main Nov 19, 2024
29 checks passed
@hamzaremmal hamzaremmal deleted the fix-i20511 branch November 19, 2024 10:39
@WojciechMazur WojciechMazur added this to the 3.6.3 milestone Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotty crashes while compiling this file (its an invalid scala program)
4 participants