Skip to content

Cannot always print help from compiler #2779

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
lrytz opened this issue Mar 6, 2024 · 4 comments · Fixed by #2781
Closed

Cannot always print help from compiler #2779

lrytz opened this issue Mar 6, 2024 · 4 comments · Fixed by #2781
Labels
bug Something isn't working help All the issues related to improving help outputs scalac compatibility Issues tied with compatibility with the scalac (compiler) command.

Comments

@lrytz
Copy link

lrytz commented Mar 6, 2024

Version 1.1.3

Using -X is ok, but -Xlint:help not.

➜ sandbox scala-cli compile -S 2 -X
Usage: scalac <options> <source files>

Available advanced options:
  -Xasync                          Enable the async phase for scala.async.Async.{async,await}. [false]
...


➜ sandbox scala-cli compile -S 2 -Xlint:help
[error]  No inputs provided (expected files with .scala, .sc, .java or .md extensions, and / or directories).
➜ sandbox

It works when using plain scala-cli without the compile subcommand.

@lrytz lrytz added the bug Something isn't working label Mar 6, 2024
@lrytz
Copy link
Author

lrytz commented Mar 6, 2024

Related to #753

@Gedochao
Copy link
Contributor

Gedochao commented Mar 6, 2024

This is caused by the fact that printing (help) options from the compiler currently need to be hard-tagged as such in the CLI code, otherwise the CLI will still require inputs to be passed, as it doesn't know a build won't be necessary.

We should be able to solve this (and other problems) permanently for Scala 3 compiler options after scala/scala3#19766 gets released.
Something similar could be possible for Scala 2 options, if we had the API somewhere.

@Gedochao
Copy link
Contributor

Gedochao commented Mar 6, 2024

@lrytz as a workaround, you can just pass dummy inputs alongside -Xlint:help to get the output.

scala-cli compile -e 'println("dummy")' -S 2 -Xlint:help
# Compiling project (Scala 2.13.13, JVM (17))
# Enable recommended warnings
#   adapted-args            An argument list was modified to match the receiver.
#   nullary-unit            `def f: Unit` looks like an accessor; add parens to look side-effecting.
#   (...)
# Default: All choices are enabled by default.
# Error compiling project (Scala 2.13.13, JVM (17))
# Compilation failed

The Compilation failed message may be confusing, this is because the CLI assumed the compiler would, well, compile, rather than print help.

@Gedochao Gedochao added scalac compatibility Issues tied with compatibility with the scalac (compiler) command. help All the issues related to improving help outputs labels Mar 6, 2024
@lrytz
Copy link
Author

lrytz commented Mar 14, 2024

@lrytz as a workaround, you can just pass dummy inputs

Or not use the compile subcommand, e.g., scala-cli -S 2 -opt:help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help All the issues related to improving help outputs scalac compatibility Issues tied with compatibility with the scalac (compiler) command.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants