Repository navigation
Description
MRI writes every rb_warn to stderr. rbgo writes them to stdout, so a program's output stream carries diagnostics that belong on the error stream.
Measured on wave32/kern (#666), which is the first branch to emit these warnings at all:
$ cat warntest.rb
x = [1,2].index(1) { :blk }
$ rbgo warntest.rb 2>/dev/null
warntest.rb:1: warning: given block not used # ← should be silent
vm.go:963 sets errOut = out, and cmd/rbgo/main.go passes os.Stdout for out, so the two streams are the same file.
Why this matters more than it looks
- It breaks piping. Anything that reads rbgo's stdout —
rbgo gen.rb > out.json, a shell pipeline, an embedder capturing output — gets warning text mixed into the payload. A warning is not an error and must not be fatal, but it must not be data either. - It hid itself from the conformance suite. The specs pass because mspec's
complainmatcher swaps$stderrfor a capture object, and$stderris a Ruby-level global that rbgo honours. So the suite never observed which real file descriptor the warning reached. This is the same shape as mspec shim: should.equal? asserts nothing — 765 uses across 328 corpus files #655: a harness that cannot see a defect reports the defect as absent. - It is why warnings were suppressed rather than fixed. wave 32 (kernel/numeric): a hang that hid 45 examples, MatchData encodings, the generic Numeric surface, Symbol#name (+162) #666's author found a comment in
Array#fetchexplaining that the previous author declined to emit these warnings at all — plausibly because emitting them on stdout was visibly wrong. Fixing the stream unblocks a family ofgiven block not usedexamples acrosscore/arrayandcore/hash.
What it needs
errOut must be a distinct writer, defaulting to os.Stderr in cmd/rbgo/main.go, with $stderr reassignment still routed through it so complain keeps working. Worth checking at the same time whether anything else writes diagnostics through out — warn, $stderr.puts, the uncaught-exception report and the deprecation path should all agree.
Found while landing #666 (core/kernel, numerics, symbols). vm.go and cmd/rbgo/main.go were outside that lane's file set, so it was reported rather than reached for.
Activity
Tests for #667, #670 and the copy_stream #to_io order
Warnings reach stderr, not stdout (#667); Tempfile ORs its mode: with…