Repository navigation
Conversation
A hex number written only with the digits 0 to 9 reached the sum reader first, which takes an x between numbers for times: 0x10, 0x400 and 0x80 all answered 0. The sum reader now leaves an x right after a 0 that starts a number to Calc.base, which reads it as hex. "0 x 10" with spaces, "10x10" and "1.0x10" are still sums.
[Low impact] The PR appears safe to merge; no actionable defects were found. SummaryThe calculator now leaves digit-only hex numbers such as
Reviews (1) · Last reviewed commit: "Read 0x10 in the field's calculator as s..." · Reviewed by Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The command field's calculator reads
0x10as sixteen, a hex number, instead of 0 × 10.0x400is 1,024, not 0.Fixes #1140
Why it happened
Calc.answerasks the sum reader beforeCalc.base. The sum reader (Sum.answer) takes anxbetween two numbers for times, so a hex number written only with the digits 0 to 9 was zero times the rest. One with a letter in it (0xff) can't be a sum, so it reachedCalc.base.Sum.answernow leaves anxright after a0that starts a number toCalc.base, which reads0x10as hex. Sums with an x for times read as before:3x4,10x10,1.0x10, and0 x 10with spaces. A hex number inside a sum (0x10+1) now gets no answer instead of 1, since the calculator doesn't read hex inside a sum.Proof
mainand passes here:swift test --filter CalcTests(aHexNumberInDecimalDigitsIsNotASum)I can't build Yab here (no Xcode). Instead I compiled
Calculator.swifton its own, with a stub forStore, and ran the synchronous tests ofCalcTeststhrough a small runner. That is 17 tests; the async rate tests and the artwork test need the app.main0x100x4000x10+10xff10x101.0x100 x 10On
mainthe new test fails on 5 of its lines. Every other test the runner covers passes on both. The sums inFieldTests(3x4and the rest) have no0xin them.Checked on
Calculator.swiftcompiled and run on macOS 27.2.1 with Swift 6.2.1.Checklist
swift testpasses (or the suites this touches: list them):CalcTests, not run withswift testhere; the runner above covers its synchronous tests./design-check --headis clean, or each exception says why with// design:NativeActions.swift(none)This adds one check at the top of
Sum.answer, away from the lines #946 (Calc.base) and #959 (Sum.Parser) change.Written by an AI coding agent (Claude Code, Claude Opus 5.5) at my request.