feat: support Ruby symbol literals (:symbol) with $_symbols_ global list#314
Merged
takaokouji merged 11 commits intodevelopfrom Mar 16, 2026
Merged
feat: support Ruby symbol literals (:symbol) with $_symbols_ global list#314takaokouji merged 11 commits intodevelopfrom
takaokouji merged 11 commits intodevelopfrom
Conversation
Add symbol collection mechanism (_collectSymbol) and $_symbols_ list creation (_createSymbolsList) as foundation for Ruby symbol support. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feature/ruby-symbol-support/ |
When a symbol is used where .to_s is needed (e.g., move(:foo)), show a specific error suggesting to add .to_s instead of generic "wrong instruction" error. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
:foo displays as シンボル「foo」 with furigana rendering. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test Ruby → Blocks → Ruby conversion for :symbol.to_s, variable assignment, comparison, and implicit say/think conversion. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a variable with dataType='symbol' is used in say/think/puts/p/print, wrap it in data_itemoflist to look up the symbol name from $_symbols_ list. Also change $_symbols_ to store names without colon prefix. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Symbols cannot be used in arithmetic (+, -, *, /, %, **) or compared with non-symbols using >, <, >=, <=. Add specific error messages with .to_s suggestion. Matches Ruby's NoMethodError/ArgumentError behavior. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These files are entirely Smalruby-specific, so inline Start/End markers are redundant. File-level markers at the top are sufficient. Refs #313 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions bot
pushed a commit
that referenced
this pull request
Mar 16, 2026
…symbol-support feat: support Ruby symbol literals (:symbol) with $_symbols_ global list
22 tasks
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
Ruby のシンボルリテラル
:symbolを Smalruby で扱えるようにする。シンボルはグローバルリスト$_symbols_で管理し、data_itemnumoflistブロックでインデックスを参照することで高速な比較を実現する。Closes #313
Implementation Steps
$_symbols_リスト管理基盤 — パーザー内でシンボル収集、Stage 上にグローバルリスト作成data_itemnumoflistブロック —visitSymbolNode拡張、@ruby:symbol:fooコメント付与:symbol.to_sサポート —operators.jsに'symbol'レシーバ追加say/puts/p/printでシンボル暗黙変換 — 各ハンドラでシンボル引数の暗黙文字列変換symbolNeedsToSエラー追加、ロケール追加@ruby:symbolコメント検出、シンボルリテラル・$_symbols_出力_handleSymbolNodeでシンボル「foo」表示$_symbols_管理、エラーケースDefinition of Done
:foo.to_sを Ruby タブで入力 → エラーなしで変換、ブロック表示されるsay(:foo)→ 正常にブロック変換、「foo と言う」ブロック表示$a = :foo→data_itemnumoflistブロックで変数にインデックス格納:foo == :bar→operator_equalsで比較ブロック生成move(:foo)→ 「.to_s を付けてください」エラーメッセージ表示self.when(:flag_clicked)→ 既存動作が壊れていない:fooリテラルが正しく出力される:fooにふりがなシンボル「foo」が表示されるTest Plan
$_symbols_管理