Skip to content

Update to 1.0.0-RC2 triggers 'assertion failed: asTerm called on not-a-Term val <none>' #2128

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

Closed
sbrunk opened this issue May 19, 2023 · 3 comments · Fixed by #2136
Closed
Labels
bug Something isn't working script-wrapper

Comments

@sbrunk
Copy link

sbrunk commented May 19, 2023

Version(s)
1.0.0-RC2

Describe the bug
After upgrading to 1.0.0-RC2 the script below fails to compile with the following error:

Error: Unexpected error when compiling project_8be8567734-de847ff703: 'assertion failed: asTerm called on not-a-Term val <none>'

System: Tried Ubuntu 23.04 and 22.04 so far

To Reproduce

//> using scala "3.2.2"
//> using jvm "17"
//> using lib "com.github.alexarchambault::case-app:2.1.0-M24"

import caseapp._

case class Options(
  domain: String = "development"
)

object BuildAndRegister extends CaseApp[Options] {
  override def run(options: Options, remainingArgs: RemainingArgs): Unit = {}
}
scala-cli compile script.sc

Note that the bug only appears to occur on Scala 3 in combination with a script:

scala-cli --cli-version 1.0.0-RC2 compile script.sc # error
scala-cli --cli-version 1.0.0-RC1 compile           # works
scala-cli compile --scala-version 2.13              # also works

mv script.sc script.scala
scala-cli compile script.sc # works

Also, if we remove the default arg in the options case class, it also works again:

case class Options(
-  domain: String = "development"
+ domain: String
)

I haven't been able to minimize the example further yet.

One hunch is that the new class based wrapping triggers something here as it happens only in scripts.

Expected behaviour
The script should compile like in earlier versions.

@sbrunk sbrunk added the bug Something isn't working label May 19, 2023
@Gedochao
Copy link
Contributor

Probably related to #2117
I'd also bet it's because of the class wrapper, as suggested in the issue description (may need further investigation, though)

@MaciejG604
Copy link
Contributor

A new flag and using directive were added for forcing the object wrapper in scripts. You can use --object-wrapper or using objectWrapper as a workaround for the mentioned problem.

@sbrunk
Copy link
Author

sbrunk commented May 26, 2023

Thanks for letting me know @MaciejG604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working script-wrapper
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants