Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

som-snytt
Copy link
Contributor

Fixes #16072

@som-snytt
Copy link
Contributor Author

som-snytt commented Sep 11, 2025

Note that it's less helpful if scanner issues the indent warning "out of order".

-- Warning: tests/warn/i16072.scala:4:2 --------------------------------------------------------------------------------4 |  def x = 1 // warn too far right
  |  ^
  |  Line is indented too far to the right, or a `{` or `:` is missing
-- [E222] Syntax Warning: tests/warn/i16072.scala:3:7 ------------------------------------------------------------------3 |object Hello_: // warn colon in name without backticks because the body is empty
  |       ^^^^^^^
  |       name `Hello_:` should be enclosed in backticks

Must follow up givens and enums.

@som-snytt som-snytt force-pushed the issue/16072-trailing-colon-template-name branch from 26646c6 to 53d4ff7 Compare September 11, 2025 22:53
This is to guard the edge case `object X_:` where the user
may or may not have intended colon syntax. The next line does
not tell us, since it may be indented yet not nested. Therefore,
any empty template with a suspicious name will warn. Non-empty
templates are given a pass even if written `object X_: :`.
When the user accidentally writes `val x_: Int` where the colon
belongs to the identifier as an operator suffix, tell them so.
@som-snytt som-snytt force-pushed the issue/16072-trailing-colon-template-name branch from 28e072e to d32f88d Compare September 12, 2025 07:56
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.

Surprising parsing behaviour for objects ending with _
1 participant