Skip to content
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

Warning for infinite recursive lazy vals #13749

Merged
merged 5 commits into from Oct 22, 2021
Merged

Conversation

gagandeepkalra
Copy link
Contributor

Fixes #13011

Part of the issue spree

Co-authored-by: Tom Grigg griggt@users.noreply.github.com
Co-authored-by: Nicolas Stucki nicolasstucki@users.noreply.github.com
Co-authored-by: Timothée Andres timothee.andres@epfl.ch

Co-authored-by: Tom Grigg <griggt@users.noreply.github.com>
Co-authored-by: Nicolas Stucki <nicolasstucki@users.noreply.github.com>
Co-authored-by: Timothée Andres <timothee.andres@epfl.ch>
@dwijnand
Copy link
Member

The scripted test change seems correct. I'm not sure what the original intent of scala> lazy val a: SelChannel[("A", "B", "C")] = a was, so if someone could review that commit/PR and rectify the test.


def firstDigitIsEven(n: Int): Boolean = if n % 10 == n then n % 2 == 0 else firstDigitIsEven(n / 10)

lazy val simple4: String = if firstDigitIsEven(22) then this.simple4 else "a" // error
Copy link
Member

Choose a reason for hiding this comment

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

Deja-vu, then: this shouldn't error, because it's only conditionally recursive, which we bias to not warning (IIRC). I don't understand why this is passing CI.

Copy link
Member

Choose a reason for hiding this comment

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

We only check the condition:

      case If(cond, _, _) =>
        checkNotLooping(cond)

Is this erroring as a consequence of being a lazy val?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no there's no error, it's my bad, I forgot to put ok there, testCompilation was indeed failing

I've pushed in the fix now.

@dwijnand dwijnand merged commit 9f06976 into scala:master Oct 22, 2021
@Kordyjan Kordyjan added this to the 3.1.2 milestone Aug 2, 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 initialization of given can wait forever in macro
4 participants