strict-truthiness fixes !!x whole: no more x === 0 === 0 #152

Merged
sionzee merged 2 commits from double-not-fix into main 2026-11-24 11:39:07 +01:00
Owner

From adopter feedback: the quick fix on !!c.interrupt[feeling] wrote c.interrupt[feeling] === 0 === 0, which is always false.

Cause. The walk took the inner !x of !!x as the test. Compare with 0 replaced only that inner part with x === 0, and the re-check then rewrote the outer !(x === 0) again.

Fix. The walk now counts the !s. An even number cancels out, and the fix replaces the whole !!x: !!n becomes n !== 0 or n > 0. !!!n becomes n === 0.

Tests. New cases in tests/fixes.rs. The meaning harness (tests/meaning.rs) gets !!$X and !!$X && … shapes: it reports 211 problems without the fix and passes with it. cargo nextest run --workspace: 413 passed. npm run test:docs passes.

Docs: the strict-truthiness quick-fix table and a CHANGELOG entry.

🤖 Generated with Claude Code

From adopter feedback: the quick fix on `!!c.interrupt[feeling]` wrote `c.interrupt[feeling] === 0 === 0`, which is always false. **Cause.** The walk took the inner `!x` of `!!x` as the test. *Compare with 0* replaced only that inner part with `x === 0`, and the re-check then rewrote the outer `!(x === 0)` again. **Fix.** The walk now counts the `!`s. An even number cancels out, and the fix replaces the whole `!!x`: `!!n` becomes `n !== 0` or `n > 0`. `!!!n` becomes `n === 0`. **Tests.** New cases in `tests/fixes.rs`. The meaning harness (`tests/meaning.rs`) gets `!!$X` and `!!$X && …` shapes: it reports 211 problems without the fix and passes with it. `cargo nextest run --workspace`: 413 passed. `npm run test:docs` passes. Docs: the strict-truthiness quick-fix table and a CHANGELOG entry. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
strict-truthiness fixes !!x whole: no more x === 0 === 0
Some checks failed
Benchmarks / bench (pull_request) Successful in 4m1s
Tests / test (pull_request) Failing after 14m37s
4d05894eba
The quick fixes took the inner `!x` of `!!x` as the test, so *Compare with 0*
wrote `x === 0` inside the outer `!`, and the re-check turned that into
`x === 0 === 0`, always false. The walk now counts the `!`s: an even number
cancels, and the fix replaces the whole `!!x` with the test for `x`.

The meaning harness gets `!!$X` shapes (211 problems before the fix).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge main
Some checks failed
Tests / test (pull_request) Has been cancelled
Benchmarks / bench (pull_request) Has been cancelled
58c2dbf89d
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sionzee deleted branch double-not-fix 2026-11-24 11:39:07 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Evobug/Safe-Ts!152
No description provided.