Skip to content

Conversation

som-snytt
Copy link
Contributor

Move the caret closer to the real problem; clarify the error.

Fixes #23815

@som-snytt
Copy link
Contributor Author

It looks like an error at EOF has a different line number when there is a newline at EOF.

-package x0
+package x0 // error
 class x0  // error
-// error
\ No newline at end of file
+// anypos-error

@som-snytt som-snytt force-pushed the disc/17874-inner-pkg-syntax-error branch 3 times, most recently from f380152 to 5c42107 Compare August 26, 2025 14:13
@som-snytt
Copy link
Contributor Author

Added a commit to move the caret at EOF if NL is at EOF.

Offset of EOF was changed at 47f4e3f

This commit doesn't revert that; it only tweaks the rendering; tools will still see the same Diagnostic.

In particular, vulpix correlates diagnostic position with the line on which it sees // error. Error at EOF with normal terminal NL still needs // anypos-error. Separately, vulpix could be made to accept // error\n in that case.

Note Scala 2 always ensured source content ended with NL; not sure how that interacted with REPL parsing.

@som-snytt som-snytt force-pushed the disc/17874-inner-pkg-syntax-error branch from 5c42107 to dab4466 Compare August 26, 2025 16:56
@som-snytt som-snytt marked this pull request as ready for review August 27, 2025 05:14
@Gedochao Gedochao requested a review from noti0na1 August 27, 2025 08:54
@Gedochao Gedochao requested a review from tgodzik August 27, 2025 08:54
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

@som-snytt
Copy link
Contributor Author

I hope the rendering diff is entirely benign; the test rig tweak is at least internal; and the nested package message is correct.

For example, the following is not accepted ever:

package p
class C
package q
end q

@som-snytt som-snytt merged commit 98a319a into scala:main Aug 27, 2025
45 checks passed
@som-snytt som-snytt deleted the disc/17874-inner-pkg-syntax-error branch August 27, 2025 15:03
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.

Improve syntax error message for nested packaging missing braces
3 participants