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

scala 3 compiler version msg is written to stdout, not stderr #18845

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/config/CliCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package config

import scala.language.unsafeNulls

import dotty.tools.dotc.reporting.ConsoleReporter
import java.io.{ BufferedReader, PrintWriter }
import Settings._
import core.Contexts._
import printing.Highlighting
Expand Down Expand Up @@ -130,7 +132,8 @@ trait CliCommand:
report.echo(ifErrorsMsg)
None
else if settings.version.value then
report.echo(versionMsg)
// ctx defaults to Console.err
ConsoleReporter(writer = new PrintWriter(Console.out, true)).printMessage(versionMsg)
Copy link
Member

@bishabosha bishabosha Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be handled by the reporter instead, then in the ConsoleReporter you can add an extra writer for where echo messages go (set to Console.out by default), and intercept Info diagnostics in doReport to send to the echo writer. This is what Scala 2 does.

Typically we do want all echo messages to go be visible in the same UI as the warnings/errors (e.g. in an IDE so you get the info messages in a dedicated window, rather than suddenly an extra Console.out log appearing).

None
else if isHelpFlag then
report.echo(helpMsg)
Expand Down