UPLC: handle JS boolean in the Bool constant encoder
メンテナーはふだん 7 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- compilers
調査の方向性
packages/evolution/src/UPLC.ts の L954 付近にある Bool エンコーダーから始め、次に L194 と L1282 付近の ConstantValue および constantTerm の定義と、L660 付近のデコーダーを読みます。Issue で説明されているリグレッションカバレッジを追加し、false と true が異なる flat バイト列を生成し、false がインデックス 0 にデコードされることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
The flat encoder for a Bool constant reads value.index, but ConstantValue also permits a plain JS boolean. A JS false has no .index, so (false).index === 0n is false and the encoder emits the True bit. con bool false and con bool true then produce identical flat bytes, so a script built from a false boolean computes that constant as true. Narrow in practice (parameter application uses con data, never con bool), but the public type invites the call that triggers it.
Affected
packages/evolution/src/UPLC.ts Bool encoder (L954)
packages/evolution/src/UPLC.ts ConstantValue type (L194), constantTerm (L1282)
decoder representation: UPLC.ts (L660)
Fix
Handle the primitive form the type advertises in the encoder, e.g.
const bit = typeof value === "boolean" ? (value ? 1 : 0) : (value.index === 0n ? 0 : 1)
Or drop boolean from ConstantValue so { index } is the only representation and the footgun cannot typecheck.
Regression test
- given: a program whose body is constantTerm("Bool", false)
- before fix: flat(con bool false) === flat(con bool true), and decoding flat(con bool false) yields index 1 (True)
- after fix: flat(con bool false) !== flat(con bool true), and decoding flat(con bool false) yields index 0 (False)
Must FAIL on main today and PASS after the fix.
Reference
Report 11
- 主要言語
- TypeScript
- スター
- 22
- フォーク
- 30
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 13
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IntersectMBO/evolution-sdk のほかの issue
-
Published types: `TransactionBuilder.d.ts` imports `DeferredRedeemer`, which `stripInternal` removesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
IntersectMBO/evolution-sdk#554 ·
メンテナーはふだん 7 日以内に返信
-
dependencies good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 93/100
IntersectMBO/evolution-sdk#541 ·
メンテナーはふだん 7 日以内に返信
-
bug external-review
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
IntersectMBO/evolution-sdk#530 ·
メンテナーはふだん 7 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
IntersectMBO/evolution-sdk#518 ·
メンテナーはふだん 7 日以内に返信
-
enhancement external-review
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
IntersectMBO/evolution-sdk#456 · コメント 1 件 ·
メンテナーはふだん 7 日以内に返信
IntersectMBO/evolution-sdk の issue をすべて見る
似ている issue
-
check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Fission-AI/OpenSpec#1986 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nestjs/docs.nestjs.com#3554 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
publicodes/publicodes#868 ·
-
namespace operations
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
EclipseFdn/open-vsx.org#13488 ·
メンテナーはふだん 2 日以内に返信