From e9dd31b04324d9a95acf6561a4b6ebcee9d3b8c0 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 17 Sep 2026 08:58:26 +0200 Subject: docs: note that sun_t passes a NaN timestamp through NaN is a number, so the type guard admits it, and every comparison against NaN is false, so neither clamp catches it and the function returns NaN. Left unguarded on purpose. No caller can produce it: parse() matches %d+ for the sun times and `now` is os.time(). If one ever did, Cairo ignores a NaN coordinate, so the arc would lose its dot rather than the dashboard going blank. A ponytail: comment names the ceiling and where the guard would go. Found while probing the committed code, not by the tests, which do not cover NaN. Co-Authored-By: Claude Opus 5 --- docs/superpowers/plans/2026-09-17-weather-widget.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs/superpowers/plans') diff --git a/docs/superpowers/plans/2026-09-17-weather-widget.md b/docs/superpowers/plans/2026-09-17-weather-widget.md index cf485ee..c394943 100644 --- a/docs/superpowers/plans/2026-09-17-weather-widget.md +++ b/docs/superpowers/plans/2026-09-17-weather-widget.md @@ -431,6 +431,11 @@ function M.sun_t(now, sunrise, sunset) or type(sunset) ~= 'number' then return nil end local span = sunset - sunrise if span <= 0 then return 0 end -- polar day/night or bad data: no division + -- ponytail: a NaN timestamp slips through, since NaN is a number and every + -- comparison against it is false, so both clamps below fall through and this + -- returns NaN. Unreachable today: parse() matches %d+ for the sun times and + -- `now` is os.time(). Cairo ignores a NaN coordinate, so the cost would be a + -- missing dot, not a crash. Guard it here if a caller ever computes `now`. local t = (now - sunrise) / span if t < 0 then return 0 elseif t > 1 then return 1 end return t -- cgit v1.2.3