Skip to content

Check inline expansion for exclusion #23019

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Apr 19, 2025

Fixes #23018

Preserve attachments on literals, check inline expansions for them, and avoid warning about purity when an inline expansion is a constant unit literal (such as assert(true) and similar reductions).

(The lint for "non-unit value in statement position" specifically does not warn. However, the purity check still warns for explicit parens, since they may have been intended as part of an application.)

Scala 2 warns at refchecks and at that time drills into the tree shapes that may have the attachment.

The test shows status quo, where 42: Unit incorrectly warns, ironically.

@ahoy-jon
Copy link

Already 😮! Thank you @som-snytt!

@som-snytt
Copy link
Contributor Author

In scala 2, these checks are all pushed to refchecks. (I may have intended to follow up with that here.)

Also #20408

@som-snytt som-snytt force-pushed the issue/23018-trans-inline-discard branch from b38dad6 to 633bb6a Compare May 20, 2025 21:11
@som-snytt
Copy link
Contributor Author

Saving phase checkWaste for future tweak.

@som-snytt
Copy link
Contributor Author

This is a good one.

[warn] 282 |    assert(6 * ChunkBits == ScalaFlagEnd)
[warn]     |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn]     |    A pure expression does nothing in statement position

Preserve attachments of literal constant in `42: Unit`.
@som-snytt som-snytt force-pushed the issue/23018-trans-inline-discard branch from 633bb6a to c489b70 Compare June 2, 2025 19:16
@som-snytt som-snytt marked this pull request as ready for review June 2, 2025 20:15
@Gedochao Gedochao requested a review from sjrd June 11, 2025 07:28
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.

Transparent inline skip warnings on value-discard
3 participants