Skip to content

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

This is a good one.

[warn] 282 | assert(6 * ChunkBits == ScalaFlagEnd) [warn] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [warn] | A pure expression does nothing in statement position 
@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
@som-snytt som-snytt force-pushed the issue/23018-trans-inline-discard branch 2 times, most recently from 26916d7 to 33e2a3c Compare October 28, 2025 17:21
Preserve attachments of literal constant in `42: Unit`.
@som-snytt som-snytt force-pushed the issue/23018-trans-inline-discard branch from 33e2a3c to b085760 Compare November 20, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants