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

Compiler hangs instead of throwing error when expanding anonymous function #19334

Closed
szymon-rd opened this issue Dec 26, 2023 · 2 comments · Fixed by #19338
Closed

Compiler hangs instead of throwing error when expanding anonymous function #19334

szymon-rd opened this issue Dec 26, 2023 · 2 comments · Fixed by #19338
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@szymon-rd
Copy link
Contributor

Compiler version

Hangs on 3.4.0-RC1-bin-20231223-938d405-NIGHTLY
Fails to compile on 3.3.0

Minimized code

//> using scala 3.4.0-RC1-bin-20231223-938d405-NIGHTLY

def foo[T](f: T): T = ???

@main
def main =
  foo {
    def f() = { }
    f(_)
  }

Output

On 3.4.0-RC1-bin-20231223-938d405-NIGHTLY:

Compiling project (Scala 3.4.0-RC1-bin-20231223-938d405-NIGHTLY, JVM)
<hangs forever>

On 3.3.0:

[error] ./Main.scala:9:7
[error] Missing parameter type
[error] 
[error] I could not infer the type of the parameter _$1 of expanded function:
[error] _$1 => f(_$1).
[error]     f(_)
[error]   

Expectation

Unsure, I don't know what change caused this.

@szymon-rd szymon-rd added itype:bug area:typer regression This worked in a previous version but doesn't anymore labels Dec 26, 2023
@som-snytt
Copy link
Contributor

    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-git-beaf7b4
            settings: -Vprint List(all) -d /tmp/sandbox

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.util.Arrays.copyOf(Arrays.java:3541)
        at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:242)
        at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:587)
        at java.base/java.lang.StringBuilder.append(StringBuilder.java:179)
        at scala.StringContext$.standardInterpolator(StringContext.scala:461)
        at dotty.tools.dotc.printing.Formatting$StringFormatter.assemble(Formatting.scala:147)
        at dotty.tools.dotc.core.Decorators$.i(Decorators.scala:315)
        at dotty.tools.dotc.reporting.Message$Seen.explanations(Message.scala:208)
        at dotty.tools.dotc.reporting.Message.msgPostscript(Message.scala:329)
        at dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:374)
        at dotty.tools.dotc.reporting.Message$$Lambda/0x00007fc2f830ab38.apply(Unknown Source)
        at dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:370)
        at dotty.tools.dotc.reporting.Message.message(Message.scala:374)
        at dotty.tools.dotc.printing.PlainPrinter.toText$$anonfun$1(PlainPrinter.scala:251)
        at dotty.tools.dotc.printing.PlainPrinter$$Lambda/0x00007fc2f8398c28.apply(Unknown Source)
        at dotty.tools.dotc.printing.MessageLimiter.controlled(MessageLimiter.scala:23)
        at dotty.tools.dotc.printing.PlainPrinter.controlled(PlainPrinter.scala:39)
        at dotty.tools.dotc.printing.PlainPrinter.toText(PlainPrinter.scala:317)
        at dotty.tools.dotc.printing.RefinedPrinter.toText$$anonfun$1(RefinedPrinter.scala:322)
        at dotty.tools.dotc.printing.RefinedPrinter$$Lambda/0x00007fc2f8398970.apply(Unknown Source)
        at dotty.tools.dotc.printing.MessageLimiter.controlled(MessageLimiter.scala:23)
        at dotty.tools.dotc.printing.PlainPrinter.controlled(PlainPrinter.scala:39)
        at dotty.tools.dotc.printing.RefinedPrinter.toText(RefinedPrinter.scala:324)
        at dotty.tools.dotc.reporting.Message$Printer.toText(Message.scala:244)
        at dotty.tools.dotc.printing.PlainPrinter.argText(PlainPrinter.scala:125)
        at dotty.tools.dotc.printing.RefinedPrinter.toTextFunction$$anonfun$1(RefinedPrinter.scala:179)
        at dotty.tools.dotc.printing.RefinedPrinter$$Lambda/0x00007fc2f83b7770.apply(Unknown Source)
        at dotty.tools.dotc.printing.Printer.atPrec(Printer.scala:44)
        at dotty.tools.dotc.printing.Printer.changePrec(Printer.scala:72)
        at dotty.tools.dotc.printing.RefinedPrinter.toTextFunction(RefinedPrinter.scala:180)
        at dotty.tools.dotc.printing.RefinedPrinter.appliedText$1(RefinedPrinter.scala:248)
        at dotty.tools.dotc.printing.RefinedPrinter.toText$$anonfun$1(RefinedPrinter.scala:259)

@som-snytt
Copy link
Contributor

som-snytt commented Dec 26, 2023

Is scala-cli handing off to a build server that fails? I can confirm that scala-cli just hangs while scalac tells me the ugly truth.

➜  snips type -a scala-cli
scala-cli is /home/.../.local/share/coursier/bin/scala-cli
➜  snips scala-cli -version
Scala CLI version: 1.0.0-RC2
Scala version (default): 3.2.2
Your Scala CLI version is outdated. The newest version is 1.1.0
It is recommended that you update Scala CLI through the same tool or method you used for its initial installation for avoiding the creation of outdated duplicates.

After updating

➜  snips scala-cli i19334.scala
Downloading compilation server 1.5.11-sc-3
Starting compilation server
[E] Caught bloop.data.Project$ProjectReadException: Failed to load project from /home/.../snips/.scala-build/.bloop/project_b4cea351c7-22e2a0c46c.json
Bloop 'bsp' command exited with code 1. Something may be wrong with the current configuration.
Running the clean sub-command to clear the working directory and remove caches might help.
If the error persists, please report the issue as a bug and attach a log with increased verbosity by passing -v -v -v.
Error: java.lang.RuntimeException: Bloop BSP connection in /home/.../.cache/scalacli/bsp-sockets/proc-8258 was unexpectedly closed or bloop didn't start.
For more details, please see '/home/.../snips/.scala-build/stacktraces/1703629595-1307502890173495753.log'

Those instructions are not meaningful to me. I just rm rf .scala-build. Then of course it just hangs.

I'll continue to avoid that toolchain as long as possible. Maybe it's great when everything just works? But when does that ever happen?

3.3.2-RC1-bin-20230718-da16f43-NIGHTLY is first hanging nightly.

That is b7e797d
#18190

That added more explanation, which is unhappy here explaining the expected type T which has an erroneous lower bound, apparently.

@som-snytt som-snytt added area:reporting Error reporting including formatting, implicit suggestions, etc and removed area:typer labels Dec 27, 2023
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants