Split borderline °F temperature assertion into sub-expressions#24
Conversation
NeedleInAJayStack
left a comment
There was a problem hiding this comment.
Hey, thanks for submitting this fix! I hadn't considered the compiler complexity when I wrote this. I think it would actually make more sense to just switch to the literal double that represents 1F in Kelvin within our acceptable margin of error instead of computing it algorithmically. Could you make that change?
The 1°F assertion computed its expected kelvin value algorithmically ((273.15 - (32 * 5.0 / 9.0)) + 5.0 / 9.0) — a mixed Int/Double expression heavy enough to exceed the Swift type-checker's per-expression budget on the macOS CI toolchain. Replace it with the equivalent literal kelvin value (255.927778 K, which converts back to 1°F well within the test's 0.0001 tolerance), removing the computation entirely. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
126fc14 to
667a8af
Compare
|
Good call — done. Replaced the algorithmic computation with the literal kelvin value for 1°F ( |
NeedleInAJayStack
left a comment
There was a problem hiding this comment.
Looks awesome! Thanks!
The
1°Fassertion intestTemperature()(DefinitionTests.swift) packs a lot into a single expression: a throwing optional unwrap, a mixedInt/Doubleliteral chain (273.15 - (32 * 5.0 / 9.0)), two.measured(in:)calls, a throwing+, and a.convert(to:). That sits right at the Swift type-checker's per-expression time budget.It compiles today, but with no margin. On a slower toolchain it tips over into:
I hit exactly this on the macOS CI runner while working on a separate change (converting
Quantityfrom an enum to aRawRepresentablestruct, which slightly raises the constraint-solver cost of every measurement expression — enough to push this one over the edge on the slower macOS compiler, while all the Linux jobs stayed green). The expression is fragile regardless of that change, so it's worth hardening on its own.This takes the compiler's own advice and splits it into typed sub-expressions — identical arithmetic and assertion:
testTemperaturepasses locally and the expression now type-checks well within budget.