{"record":{"id":"06cc21955138f9c0","repo":"mame/quine-relay","slug":"overflow-s-width-template-count","errorCode":null,"errorMessage":"overflow!: #{ s - width }->#{ TEMPLATE.count(\"#\") - width }","messagePattern":"overflow!: #(.+?)->#(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/QR.rb.gen.rb","lineNumber":102,"sourceCode":"    #{gen_prologue_1};\n    puts(eval(\n      %q(#{ s }).gsub(/[#{ ABBREV.keys.sort.join }]/){[#{ a }][$&.ord%#{ $N }%#{ $M }]}\n    ))\n\n  )*\"\"))\nEND\n\n$stderr.puts \"size: #{ code.b.size }\"\ncode.chop!\n\nTEMPLATE = File.read(\"uroboros.txt\")\nwidth = TEMPLATE[/.*/].size\nwhile TEMPLATE.count(\"#\") - width < code.size\n  s = TEMPLATE.count(\"#\")\n  line = TEMPLATE[/^#*$/]\n  TEMPLATE.replace((line + \"\\n\" + TEMPLATE + line).gsub!(/^|$/, \"######\") + \"\\n\")\n  width = TEMPLATE[/.*/].size\n  warn \"overflow!: #{ s - width }->#{ TEMPLATE.count(\"#\") - width }\"\nend\nPADDING = \"\".ljust(width, \"#_buffer_for_future_bug_fixes_\")\nCOPYRIGHT =\n  \"  Quine Relay -- Copyright (c) 2013, 2014 Yusuke Endoh (@mametter), @hirekoke  \".\n  center(width, \"#\")[0..-2]\n\ncode = TEMPLATE.gsub(/#+/) { w = $&.size; code.slice!(0, w).ljust(w, PADDING) }.chomp\ncode[-1] = \")\"\n\ncode[-1 - COPYRIGHT.size, COPYRIGHT.size] = COPYRIGHT\n\nFile.write(\"../QR.rb\", code + \"\\n\")\n","sourceCodeStart":84,"sourceCodeEnd":115,"githubUrl":"https://github.com/mame/quine-relay/blob/c2aa5098d3e95409a36185b16371089dd04db642/src/QR.rb.gen.rb#L84-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","To keep the shipped uroboros.txt stable, commit the enlarged template back to src/uroboros.txt so subsequent runs do not warn","If you want to shrink the code instead, tune the ABBREV table (lines 35-46) so the code fits the existing frame"],"exampleFix":"# before: warning fires whenever the code outgrows the art\nwarn \"overflow!: #{s - width}->#{TEMPLATE.count(\"#\") - width}\"\n\n# after: predict the overflow once, before the loop, and report it as information\nneed, have = code.size, TEMPLATE.count('#') - width\nputs \"uroboros frame too small (need #{need} cells, have #{have}); expanding border\" if need > have","handlingStrategy":"fallback","validationCode":"# Predict whether the uroboros frame will overflow before generating\ntemplate = File.read('src/uroboros.txt')\nwidth = template[/.*/].size\nhave = template.count('#') - width\nputs \"info: frame has #{have} cells; expansion will trigger if code exceeds this\" # compare with code.size after building","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read 'overflow!: a->b' as progress info, not failure: the loop auto-grows the border until the code fits","After regeneration with expansion, commit the enlarged uroboros.txt back so future runs are quiet and the artifact is reproducible","Verify the regenerated QR.rb with make check (SHA256SUMS) since the art layout changed"],"tags":["ruby","ascii-art","template","capacity","warning"],"backgroundTag":"template-capacity-overflow","analyzedSha":"c2aa5098d3e95409a36185b16371089dd04db642","analyzedAt":"2026-08-21T15:28:43.741Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}