Skip to content

Recursion limit exceeded (opaque types + inline methods) (3.7.0) #23137

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
road21 opened this issue May 12, 2025 · 2 comments
Open

Recursion limit exceeded (opaque types + inline methods) (3.7.0) #23137

road21 opened this issue May 12, 2025 · 2 comments
Assignees
Labels
area:inline area:opaque-types itype:bug regression This worked in a previous version but doesn't anymore stat:fixed in nightly This issue may be present in the latest stable or RC version of Next, but has been since fixed.

Comments

@road21
Copy link
Contributor

road21 commented May 12, 2025

Compiler version

3.7.0
(works in 3.6.4)

Minimized code

//> using scala 3.7.0

object Foo:
    class Inner // moving Inner to external object fixes the error

    opaque type Type = Inner

    inline def of[A]: OfOps = new OfOps // type A is important here
    class OfOps:
        inline def apply(): Type = new Inner

@main def run: Unit = Foo.of()

Output

Compiler error:

[error] Recursion limit exceeded.
[error] Maybe there is an illegal cyclic reference?
[error] If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
[error] For the unprocessed stack trace, compile with -Xno-enrich-error-messages.
[error] A recurring operation is (inner to outer):
[error] 
[error]   find-member Foo.Inner
[error]   find-member Foo.Inner
[error]   find-member Foo.Inner
[error]   find-member Foo.Inner
[error]   find-member Foo.Inner
[error]   find-member Foo.Inner
[error]   find-member Foo.Inner

Expectation

No compiler error

@road21 road21 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 12, 2025
fwbrasil pushed a commit to getkyo/kyo that referenced this issue May 14, 2025
Fix `pendingUntilFixed` test of `Record.stage` after migrating to 3.7.0
(in #1175)

Firstly, I have fixed problems with `unlimited recursion` which was
similar to (scala/scala3#23137). I have just
made scopes of opaque types (`AsFields, AsField`) inside `Record`
narrower.

Secondly, I have faced with interesting behavior: moving bound
`AsFields` from `unsafeFrom` to `StageOps.apply` changes compiler
result. I've spent a lot of time to minimize it to scala compiler bug,
but no succeeded.
@Gedochao Gedochao added area:inline regression This worked in a previous version but doesn't anymore area:opaque-types stat:fixed in nightly This issue may be present in the latest stable or RC version of Next, but has been since fixed. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 15, 2025
@Gedochao
Copy link
Contributor

Gedochao commented May 15, 2025

Seems to be fixed on the nightly (works in 3.7.2-RC1-bin-20250512-e52986c-NIGHTLY)

Last bad release: 3.7.1-RC1-bin-20250501-83ffe00-NIGHTLY
First good release: 3.7.2-RC1-bin-20250503-453f94d-NIGHTLY
fc41883 is the first good commit (#23059)

This means the bug is likely tied with #22974 (cc @jchyb)
Should we port the revert to 3.7.1?
cc @tgodzik @WojciechMazur

@tgodzik
Copy link
Contributor

tgodzik commented May 15, 2025

Yeah, we might need to do that. It's already in 3.3.7.nightly so we are safe on that front.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:inline area:opaque-types itype:bug regression This worked in a previous version but doesn't anymore stat:fixed in nightly This issue may be present in the latest stable or RC version of Next, but has been since fixed.
Projects
None yet
Development

No branches or pull requests

4 participants