Skip to content

Commit

Permalink
Fix an error when str.length is greater than length
Browse files Browse the repository at this point in the history
This PR fix an error when `str.length` is greater than `length`.
Reproduced by parse.y below:
https://gist.github.com/ydah/70186de8a1ff14fa2cd16b338b9fc0e0
  • Loading branch information
ydah committed Oct 12, 2024
1 parent a7842f8 commit cc7e2b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lrama/counterexamples/derivation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _render_for_report(derivation, offset, strings, index)
str << "#{item.next_sym.display_name}"
length = _render_for_report(derivation.left, len, strings, index + 1)
# I want String#ljust!
str << " " * (length - str.length)
str << " " * (length - str.length) if length > str.length
else
str << " • #{item.symbols_after_dot.map(&:display_name).join(" ")} "
return str.length
Expand Down

0 comments on commit cc7e2b0

Please sign in to comment.