mame/quine-relay · warning

overflow!: #{ s - width }->#{ TEMPLATE.count("#") - width }

Error message

overflow!: #{ s - width }->#{ TEMPLATE.count("#") - width }

What it means

When regenerating QR.rb, the final Ruby source must be embedded into the '#' cells of the uroboros ASCII-art picture (src/uroboros.txt). If the code is larger than the available cells (TEMPLATE.count('#') minus the width '#'s per row that form the border), the while loop wraps the whole picture in an extra '######' border, growing capacity, and warn prints 'overflow!: <old capacity>-><new capacity>' to stderr. This is not a failure: it is a progress notice that the artwork was auto-enlarged; the loop is guaranteed to exit once capacity >= code.size, and the expanded template changes only the '#' padding, not the program text.

Source

Thrown at src/QR.rb.gen.rb:102

    #{gen_prologue_1};
    puts(eval(
      %q(#{ s }).gsub(/[#{ ABBREV.keys.sort.join }]/){[#{ a }][$&.ord%#{ $N }%#{ $M }]}
    ))

  )*""))
END

$stderr.puts "size: #{ code.b.size }"
code.chop!

TEMPLATE = File.read("uroboros.txt")
width = TEMPLATE[/.*/].size
while TEMPLATE.count("#") - width < code.size
  s = TEMPLATE.count("#")
  line = TEMPLATE[/^#*$/]
  TEMPLATE.replace((line + "\n" + TEMPLATE + line).gsub!(/^|$/, "######") + "\n")
  width = TEMPLATE[/.*/].size
  warn "overflow!: #{ s - width }->#{ TEMPLATE.count("#") - width }"
end
PADDING = "".ljust(width, "#_buffer_for_future_bug_fixes_")
COPYRIGHT =
  "  Quine Relay -- Copyright (c) 2013, 2014 Yusuke Endoh (@mametter), @hirekoke  ".
  center(width, "#")[0..-2]

code = TEMPLATE.gsub(/#+/) { w = $&.size; code.slice!(0, w).ljust(w, PADDING) }.chomp
code[-1] = ")"

code[-1 - COPYRIGHT.size, COPYRIGHT.size] = COPYRIGHT

File.write("../QR.rb", code + "\n")

View on GitHub (pinned to c2aa5098d3)

Solutions

  1. No action required: let the loop expand the frame; then verify the regenerated QR.rb via make check (sha256sum -c SHA256SUMS) since the checked-in artifact is expected to change
  2. To keep the shipped uroboros.txt stable, commit the enlarged template back to src/uroboros.txt so subsequent runs do not warn
  3. If you want to shrink the code instead, tune the ABBREV table (lines 35-46) so the code fits the existing frame

Example fix

# before: warning fires whenever the code outgrows the art
warn "overflow!: #{s - width}->#{TEMPLATE.count("#") - width}"

# after: predict the overflow once, before the loop, and report it as information
need, have = code.size, TEMPLATE.count('#') - width
puts "uroboros frame too small (need #{need} cells, have #{have}); expanding border" if need > have
Defensive patterns

Strategy: fallback

Validate before calling

# Predict whether the uroboros frame will overflow before generating
template = File.read('src/uroboros.txt')
width = template[/.*/].size
have = template.count('#') - width
puts "info: frame has #{have} cells; expansion will trigger if code exceeds this" # compare with code.size after building

Prevention

When it happens

Trigger: Running ruby src/QR.rb.gen.rb (or rake in src/) after the generated code grew beyond the shipped uroboros.txt capacity, typically after adding languages to code-gen.rb or after edits that lengthen any stage's code.

Common situations: Extending the 50-language relay with a new language; first regeneration after significant refactors; any change to ABBREV compression in QR.rb.gen.rb that makes the final code bigger than the previous release's art.

Related errors


AI-assisted analysis of mame/quine-relay@c2aa5098d3 (2026-08-21). Data as JSON: /api/errors/06cc21955138f9c0. Report an issue: GitHub.