Skip to content

Exit on main arg parse error #22947

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 3 commits into from

Conversation

som-snytt
Copy link
Contributor

Could be a better way to construct the expr, there is Definitions.SystemModule.

Could use a test.

As a user, I never want to see stack trace from the arg mechanism. Parse error could take a cause, perhaps.

Fixes #16040

@som-snytt
Copy link
Contributor Author

som-snytt commented Apr 9, 2025

Mima body-slammed me on fiddling with ParseError, which is not internal, perhaps, so I'll retract that change.

But maybe I can get away with fixing

scala> val pe = util.CommandLineParser.ParseError(0, "uh oh")
val pe: scala.util.CommandLineParser.ParseError = scala.util.CommandLineParser$ParseError

scala> pe.getMessage
val res0: String = null

assuming that is an oversight.

@som-snytt som-snytt force-pushed the issue/16040-main-exit branch from 55ebf8b to 2867a88 Compare April 9, 2025 11:54
@som-snytt
Copy link
Contributor Author

som-snytt commented Apr 9, 2025

This is a good one.

Test 'tests/run/Pouring.scala' failed with output:                              
Illegal command line: more arguments expected

The run test was given command line args which have always been missing, and now the test correctly fails on that basis.

@som-snytt som-snytt force-pushed the issue/16040-main-exit branch from 2867a88 to 3be3459 Compare April 9, 2025 20:43
@som-snytt
Copy link
Contributor Author

I found out why they don't do that.

Referring to non-existent method static java.lang.System.exit(int)void
  called from static Test.main([java.lang.String)void
  called from core module module initializers
Test 'tests/run/quotes-add-erased' failed with output:                          
org.scalajs.linker.interface.LinkingException: There were linking errors

@som-snytt som-snytt force-pushed the issue/16040-main-exit branch from 3be3459 to f1783ec Compare April 14, 2025 21:11
Uses `// java:` syntax as a stopgap.
Args are appended to child message line.
@som-snytt som-snytt force-pushed the issue/16040-main-exit branch from f1783ec to ac71296 Compare April 16, 2025 17:25
@som-snytt
Copy link
Contributor Author

I will probably give up trying to accommodate ScalaJS.

@som-snytt som-snytt closed this Apr 17, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scala script exit code should be non-0 for missing parameters
1 participant