Skip to content
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

Output should distinguish stdout and stderr #16701

Closed
som-snytt opened this issue Jan 14, 2023 · 5 comments · Fixed by #20328
Closed

Output should distinguish stdout and stderr #16701

som-snytt opened this issue Jan 14, 2023 · 5 comments · Fixed by #20328
Labels
area:tooling good first issue Perfect for someone who wants to get started contributing itype:enhancement
Milestone

Comments

@som-snytt
Copy link
Contributor

som-snytt commented Jan 14, 2023

Compiler version

3.2.1

Output

javac --version (and help) is written to stdout, and scalac 2 follows that model of reporting only error output to stderr.

scalac 3 writes all output to stderr.

Expectation

Expect javac behavior. Not sure about the summary 19 errors which is echoed to stdout in scala 2. Edit: scala 2 prints summary count to stderr scala/scala#10272

Would expect debug output -Vprint on stdout. That is, stderr is for the tool to tell me why it could not fulfill my request.

Not sure about scala-cli or sbt compile.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 14, 2023
@Kordyjan
Copy link
Contributor

I prefer the output of -Vprint to stay in stderr, as it should be considered diagnostic data.
I, however, agree that scalac -version should output to stdout, as the version is the main output of the command, and I can see it being used in scripts.

@Kordyjan Kordyjan added itype:enhancement area:tooling good first issue Perfect for someone who wants to get started contributing and removed itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 16, 2023
@som-snytt
Copy link
Contributor Author

My criterion was "stdout for output I asked for", but "stderr to report why the tool did not do what I requested."

On Scala 2, I chose that summary N errors is stderr output. (PR not accepted yet.) The error summary clearly explains the error.

"Diagnostic data" is an interesting criterion. How is -version not diagnostic in some sense? I would stand by the criterion, "successful completion" versus "error outputs explaining a failure".

What about warnings? If I say -Xlint, then those warnings are "requested", to stdout. Are those warning stdout normally, but stderr if -Werror?

I won't try the permutations just now, but it's not obvious which output to use in all cases. It might be a "style" choice.

@som-snytt
Copy link
Contributor Author

Also scalac -help 2>&1 | grep color to jog my memory on colorization.

Note javac is on stdout, javac -help | grep proc. It makes sense because that is the successful output I requested.

Scala 2 follows java.

If the compiler were one of those sarcastic robots from science fiction, it would say, "Helpful output is not my primary function."

@ncgl-git
Copy link

Very new to scala and decided to start looking into this issue. I see us mapping --version to Repl here, and us defaulting to Console.out here.

Is Console.out not Stdout?

@som-snytt
Copy link
Contributor Author

som-snytt commented Oct 31, 2023

I see settings.version used here, but I don't know without looking further whether reporting an Info is output on a channel for info or for errors and warnings.

I'm not sure "diagnostic" is sufficiently diagnostic. Everything that is not a class file (or tasty file) is diagnostic output.

Edit: console output

I don't remember how Scala 2 works, as reporting was reworked so many times.

rochala pushed a commit that referenced this issue May 7, 2024
Fixes #16701 

Tested only manually.

For example, with `tailrec` printer enabled,
```
scalac -Vprint:typer example.scala > x 2> y
```
puts tree output and tailrec trace in x, warnings & errors & summary
count in y.

x is the output I asked for. This makes it easier to see trace and trees
correctly interleaved, since `> out 2>&1` does not guarantee it.

Tests may depend on how output is captured. Scala 2 partest captures
stderr to log, for example.
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tooling good first issue Perfect for someone who wants to get started contributing itype:enhancement
Projects
None yet
3 participants