Skip to content

fix: correct power operator guard (!value === 10value !== 10)#536

Merged
takaokouji merged 1 commit into
developfrom
fix/power-operator-base
Apr 18, 2026
Merged

fix: correct power operator guard (!value === 10value !== 10)#536
takaokouji merged 1 commit into
developfrom
fix/power-operator-base

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

!receiver.value === 10(!receiver.value) === 10 と解釈され常に false。2 ** 8 が 10 ** 8 に変換されるバグの原因。

Fix

receiver.value !== 10 に修正。10 ** n のみ 10 ^ 演算子にマッピング。

Note

10 以外のべき乗(2 ** 8 等)はブロックに変換できない(Scratch に等価な演算子がない)。既知の制限。

Found during Playwright testing on smalruby.app.

Refs #529

The guard \`!receiver.value === 10\` was parsed as
\`(!receiver.value) === 10\`, which is always false. This caused
ALL numeric ** operations (e.g. 2 ** 8) to be incorrectly
converted to the \`10 ^\` math operator, changing the base from
the original value to 10.

Fix: change to \`receiver.value !== 10\` so only \`10 ** n\` maps
to \`10 ^\`. Other bases (e.g. 2 ** 8) now correctly return null
from this handler.

Note: non-10 base power (2 ** 8) still cannot be converted to
blocks (no Scratch equivalent). This is tracked as a known
limitation.

Refs #529

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

@takaokouji takaokouji merged commit 05510bb into develop Apr 18, 2026
9 checks passed
@takaokouji takaokouji deleted the fix/power-operator-base branch April 18, 2026 16:07
github-actions Bot pushed a commit that referenced this pull request Apr 18, 2026
…rator-base

fix: correct power operator guard (`!value === 10` → `value !== 10`)
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