Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Apr 5, 2022

We previously converted an expression with constant type to a literal if
the expression was idempotent. This can hide side effects in the case where
the expression is a selection from an object or lazy val. Demanding purity
instead prodcues tons of errors involving inline vals on objects.

We now demand idempotency if the expression refers to an inline val (or
an operation over an inline val), and purity elsewhere.

Fixes #2266

odersky added 2 commits April 5, 2022 14:52
We previously converted an expression with constant type to a literal if
the expression was idempotent. This can hide side effects in the case where
the expression is a selection from an object or lazy val. Demanding purity
instead prodcues tons of errors involving inline vals on objects.

We now demand idempotency if the expression refers to an inline val (or
an operation over an inline val), and purity elsewhere.

Fixes scala#2266
@bishabosha bishabosha merged commit 8d3083b into scala:main Apr 6, 2022
@bishabosha bishabosha deleted the fix-2266 branch April 6, 2022 10:26
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
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.

Lazy val with constant type loses side effects.

3 participants