Skip to content

feat: add String#* (string repetition) for TryRuby L80 (#524)#532

Merged
takaokouji merged 3 commits into
developfrom
feat/tryruby-string-multiply
Apr 18, 2026
Merged

feat: add String#* (string repetition) for TryRuby L80 (#524)#532
takaokouji merged 3 commits into
developfrom
feat/tryruby-string-multiply

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

  • "Jimmy" * 5文字列 ("Jimmy") . [*▼] ( (5) ) ブロックにマッピング
  • ジェネレーターは中置記法 receiver * arg を生成(Ruby 慣例に合わせる)
  • 数値引数は _addNumberInput で処理(型不一致を回避)

Test Coverage

  • コンバーター: "Jimmy" * 5 変換テスト
  • ジェネレーター: * 中置記法生成テスト + finishTargets インライン化テスト
  • ラウンドトリップ: say("Jimmy" * 5, 2) → 完全一致

Refs #524 (Phase 1 #2)

Map "Jimmy" * 5 to stringMethod block with METHOD=*.
Generator emits infix notation (receiver * arg) instead of
dot notation. finishTargets regex handles * operator inlining.

Handle numeric arguments with _addNumberInput instead of
_addTextInput to avoid type mismatch.

Refs #524 (Phase 1 #2)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

takaokouji and others added 2 commits April 18, 2026 16:51
Register * method only for 'string' receiver type (not 'block'
or 'variable') to avoid conflicts with numeric multiplication
in expressions like (1.0 / 3435.0) * Math.log(20.0).

Fixes round-trip and method-return test failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
"1" * 2 and "1" * "2" are now valid String#* calls.
Only 1 * "2" (numeric receiver with string arg) remains an error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji merged commit 1887ea1 into develop Apr 18, 2026
9 checks passed
@takaokouji takaokouji deleted the feat/tryruby-string-multiply branch April 18, 2026 08:27
github-actions Bot pushed a commit that referenced this pull request Apr 18, 2026
…string-multiply

feat: add String#* (string repetition) for TryRuby L80 (#524)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant