UPLC: handle JS boolean in the Bool constant encoder
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- compilers
Research direction
Start in packages/evolution/src/UPLC.ts at the Bool encoder around L954, then read the ConstantValue and constantTerm definitions around L194 and L1282 and the decoder around L660. Add the regression coverage described in the issue and verify that false and true produce different flat bytes, with false decoding to index 0.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 30
- Avg merge
- 13h
- Merged PRs (30d)
- 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IntersectMBO/evolution-sdk
-
dependencies good first issue
Difficulty 1/5 Under an hour Newbie friendliness 93/100
IntersectMBO/evolution-sdk#541 ·
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
IntersectMBO/evolution-sdk#530 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
IntersectMBO/evolution-sdk#518 ·
-
enhancement external-review
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
IntersectMBO/evolution-sdk#456 · 1 comment ·
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
IntersectMBO/evolution-sdk#396 ·
All issues in IntersectMBO/evolution-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·