Skip to content

feat: update list handling to Ruby v2 array syntax#406

Merged
takaokouji merged 7 commits into
developfrom
feature/smalruby3-list-v2-array-syntax
Mar 28, 2026
Merged

feat: update list handling to Ruby v2 array syntax#406
takaokouji merged 7 commits into
developfrom
feature/smalruby3-list-v2-array-syntax

Conversation

@takaokouji
Copy link
Copy Markdown

@takaokouji takaokouji commented Mar 28, 2026

Summary

Ruby v2 で list() を廃止し配列リテラル [] + 0 起点インデックスを使う実態を、言語仕様・Rubytee プロンプト・smalruby3 gem に反映する。

Closes #405

Implementation Steps

  • Phase 1: ドキュメント更新 — 言語仕様書・v1 diff(EN/JA)
  • Phase 2: Rubytee プロンプト更新 — Lists セクション追加 + Sensing v2 修正
  • Phase 3: smalruby3 gem API 更新 — 0 起点 + list() 削除
  • Phase 4: scratch-gui Generator 更新 — delete_at/insert 特殊値
  • Phase 5: scratch-gui Converter 更新 — round-trip
  • Phase 6: Integration Tests

Definition of Done

  • ユニットテスト pass
  • lint pass
  • CI green
  • ブラウザ確認(Playwright MCP):
    • Ruby タブでリスト操作コードの round-trip が成功すること(全13操作確認済み)
    • delete_at(-1) + @ruby:array:delete_at:last コメントの round-trip 成功
    • Rubytee にリスト操作を含むプログラムを依頼し、v2 配列構文で生成されること(Lambda 未デプロイのため検証不可 — デプロイ後に確認
    • Rubytee の応答で Sensing が v2 構文になっていること(同上

Test plan

  • smalruby3 gem List クラスの 0 起点ユニットテスト (14 tests)
  • Generator の delete_at/insert 特殊値変換テスト (4 tests)
  • Converter の @ruby:array:delete_at:last 検出テスト (round-trip)
  • リスト操作の round-trip テスト (64 tests total)
  • Playwright MCP でブラウザ動作確認(round-trip)

🤖 Generated with Claude Code

takaokouji and others added 2 commits March 28, 2026 20:58
- Replace list() wrapper with direct array syntax (@items.push(...))
- Change from 1-indexed to 0-indexed
- Add array literal initialization (@Items = [...])
- Add empty? method
- Add Lists section to v1-diff documents (EN/JA)

Refs #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add Lists (Arrays) section with 0-indexed array operations
- Fix Sensing to v2 syntax (keyboard.pressed?, mouse.x, timer.value)
- Add list() to Forbidden Methods
- Update Critical Syntax Warnings for v2 sensing and list()

Refs #405

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

takaokouji and others added 5 commits March 28, 2026 21:07
- Change List class to 0-indexed (Ruby standard)
- index() returns nil when not found (was 0)
- [] returns nil for out-of-range (was "")
- Remove list() wrapper method from Target
- Update monitor_renderer to access list variable directly
- Delegate delete_at/insert directly to Array (no special values)

Refs #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- delete_at("last") → list.delete_at(-1) # @ruby:array:delete_at:last
- delete_at("random") → list.delete_at(rand(0...list.length)) # @ruby:array:delete_at:random
- insert("last", item) → list.push(item) # @ruby:array:insert:last
- insert("random", item) → list.insert(rand(0..list.length), item) # @ruby:array:insert:random

Refs #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generator: check @ruby:array:delete_at:last/random and
@ruby:array:insert:last/random comments for round-trip output.

Converter: detect delete_at(-1) as "last" special value and
attach @ruby:array:delete_at:last comment for round-trip.

Refs #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- empty? method round-trip
- show_list/hide_list round-trip

Refs #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ruby:array:delete_at:last/random and @ruby:array:insert:last/random
comments are round-trip metadata stored as block comments, not meant
to be visible in the Ruby editor. Remove inline comment output from
the Generator so these comments stay hidden like other @ruby: markers.

Refs #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji merged commit af65630 into develop Mar 28, 2026
17 checks passed
@takaokouji takaokouji deleted the feature/smalruby3-list-v2-array-syntax branch March 28, 2026 14:17
github-actions Bot pushed a commit that referenced this pull request Mar 28, 2026
…uby3-list-v2-array-syntax

feat: update list handling to Ruby v2 array syntax
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.

feat: update list handling to Ruby v2 array syntax (0-indexed, no list())

1 participant