Skip to content

Improve Scala compiler settings integration #2867

@lrytz

Description

@lrytz

Sorry for another ticket like #2779 / #753... I understand there are difficulties how to handle this, but the user experience can probably still be improved.

There are compiler options not forwarded by the compiler, for example

➜ sandbox scala-cli compile --server=false C.scala -- [E007] Type Mismatch Error: /Users/luc/code/scala/scala13/sandbox/C.scala:2:15 ... | longer explanation available when compiling with `-explain` 1 error found Compilation failed ➜ sandbox scala-cli compile --server=false C.scala -explain Unrecognized argument: -explain To list all available options, run scala-cli compile --help 

When a user installs Scala, runs the compiler, and the compiler tells them to add a flag (-explain), they should not need to figure out that they actually need to do -O -explain.

The approach currently is for scala-cli to forward known compiler flags. Would it be possible to pass all unrecognized arguments to the compiler by default (for compile / repl / doc)?

As a backstop, a static hint in the "Unrecognized argument" message could help. If scala-cli compile / repl / doc gets an unrecognized argument, it could suggest "Use -O ${unrecognized} to pass the argument to the Scala compiler".


Another confusing situation is because the compiler is not invoked when there are no souce files. So scala-cli compile -S 2 C.scala -opt:help works, but scala-cli compile -S 2 -opt:help doesn't.


Finally, in Scala 2 at least there are compiler options that support space separated arguments, for example -Vopt _ or -Vprint-args args.txt. The first makes scala-cli hang, the second gives an error message ([error] args.txt: unrecognized source type).

It's again not obvious for the user what's going on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmissing featureSomething should have been implemented, but wasn't.scalac compatibilityIssues tied with compatibility with the scalac (compiler) command.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions