fix: escape control characters in Ruby code generation#530
Merged
takaokouji merged 6 commits intodevelopfrom Jan 18, 2026
Merged
fix: escape control characters in Ruby code generation#530takaokouji merged 6 commits intodevelopfrom
takaokouji merged 6 commits intodevelopfrom
Conversation
Updated RubyGenerator.escapeChars_ to include control characters: - \n (newline) - \t (tab) - \r (carriage return) - \b (backspace) - \f (form feed) - \v (vertical tab) - \0 (null) Added unit tests to verify escaping of these characters. Fixes smalruby/smalruby3-develop#28
Update operators.test.js to match fix for issue #28.
Correctly use backslashes in dedent template literals to expect literal \n and \. This matches the Ruby code generator's behavior of escaping control characters.
Avoid dedent's unpredictable backslash handling by using String.raw. This ensures the test expectation accurately matches the generator's output.
github-actions bot
pushed a commit
that referenced
this pull request
Jan 18, 2026
…escape-control-characters fix: escape control characters in Ruby code generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where control characters (e.g.,
\n,\t) in Ruby code generation were not properly escaped, causing multi-line strings or literal tabs in the output Ruby code.Changes
RubyGenerator.escapeChars_insrc/lib/ruby-generator/index.jsto include:\n(newline)\t(tab)\r(carriage return)\b(backspace)\f(form feed)\v(vertical tab)\0(null)RubyGenerator.quote_intest/unit/lib/ruby-generator/index.test.js.printandputsblocks with control characters intest/unit/lib/ruby-generator/looks.test.js.Verification Results
npm run test:unit).npm run test:lint).Fixes smalruby/smalruby3-develop#28