fix: preserve class inheritance (superclass) during Ruby round-trip#290
Merged
takaokouji merged 3 commits intodevelopfrom Mar 13, 2026
Merged
fix: preserve class inheritance (superclass) during Ruby round-trip#290takaokouji merged 3 commits intodevelopfrom
takaokouji merged 3 commits intodevelopfrom
Conversation
…onversion Add superclass extraction from ClassNode and encode it in @ruby:class comment using <=path format (:: replaced by /). Stage validates only ::Smalruby3::Stage or Smalruby3::Stage as superclass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parse <=encoded_path from @ruby:class comment, decode / back to ::, and output the superclass in class definition. Non-file output uses explicit superclass or none; file output defaults to ::Smalruby3::Sprite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests Ruby → Blocks → Ruby round-trip for all superclass variants: ::Smalruby3::Sprite, Smalruby3::Sprite, Foo, Sprite, no superclass, and Stage with accepted/rejected superclasses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/fix/preserve-class-inheritance/ |
github-actions bot
pushed a commit
that referenced
this pull request
Mar 13, 2026
…class-inheritance fix: preserve class inheritance (superclass) during Ruby round-trip
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
Fixes #289 — Preserve class inheritance (superclass) during Ruby round-trip conversion.
Previously,
class Sprite1 < ::Smalruby3::Spritewould lose the superclass after round-trip, becoming justclass Sprite1. This PR encodes the superclass in the@ruby:classcomment using<=pathformat (with::→/encoding) and decodes it back in the generator.Changes Made
Converter (
ruby-to-blocks-converter/index.js)_constantNodeToPath()helper to extract superclass path from prism AST nodesvisitClassNode()to extract and validate superclass::Smalruby3::StageorSmalruby3::Stageas superclass<=pathin@ruby:classcomment (e.g.,@ruby:class:<=//Smalruby3/Sprite)invalidStageSuperclasserror messageGenerator (
ruby-generator/index.js)_wrapWithClass()to parse<=pathfrom comment attributes/back to::(leading//→::) for Ruby output::Smalruby3::SpriteTest Coverage
Implementation Steps
Closes #289
🤖 Generated with Claude Code