3.8.0 Experimental multiSpreads: great feature.. but is it currently broken?

The Scala 3.8.0 RC1 release notes include:

Experimental SIP-70: Allow multiple spreads in function arguments #23855 Allow multiple spreads in function arguments by odersky · Pull Request #23855 · scala/scala3 · GitHub

This is a great improvement I’ve wanted for some time, so first up, a :folded_hands: to @lihaoyi for specifying it, and @Odersky for implementing it.

After an hour using it in the VSCode Metals editor, doing some data wrangling involving building lots of Seqs, the utility of multiple spreads shone out.

But. It seems rough at the moment, I’m hitting a compiler error that makes it difficult to experiment with:

  1. The only way I was able to get the feature to work was to put following at top of file under package:
import language.experimental.multiSpreads

It apparently works in the presentation compiler, but in SBT builds I see this compiler crash when it’s used:

Warning: mocking up superclass for module class <special-ops>
[error] SI-5604: Cannot use package as value: This(Ident(<special-ops>))
java.lang.RuntimeException: SI-5604: Cannot use package as value: This(Ident(<special-ops>))
  | => rat dotty.tools.backend.jvm.BCodeHelpers.abort(BCodeHelpers.scala:854)
	at dotty.tools.backend.jvm.BCodeHelpers.abort$(BCodeHelpers.scala:47)
	at dotty.tools.backend.jvm.CodeGen$Impl$.abort(CodeGen.scala:174)
	at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadModule(BCodeBodyBuilder.scala:1224)
	at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:392)
	at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:303)
	at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:297)
..snip...
  1. I don’t seem to be able to enable it from Scalac command line -experimental. Even with that flag on the spread operator isn’t recognized.

I found that no reading of the docs for Experimental suggested any alternate way to enable the feature other than the language import that I could make work:

  1. The SIP is not mentioned at all on the SIPs page afaict
    List of All SIPs | Scala Documentation

Please use GitHub to raise issues, maintainers might not be scanning users forum

  1. I don’t seem to be able to enable it from Scalac command line -experimental. Even with that flag on the spread operator isn’t recognized.

It would be fixed in RC2, some setting flags were omitted by mistake.

5 Likes