diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 08:52:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 08:52:14 +0200 |
| commit | 6832a816f9965e273c104f7641c662d6d5d57ced (patch) | |
| tree | 02a25a3cff9b9ca5734ac51d8744e94bec11c7bd /lib | |
| parent | 159fabf66ca1b7e0a745165de0ef56e2631f79b8 (diff) | |
| download | conky-theme-udt-6832a816f9965e273c104f7641c662d6d5d57ced.tar.gz conky-theme-udt-6832a816f9965e273c104f7641c662d6d5d57ced.zip | |
fix: guard a nil timestamp in the icon lookup
icon(800, nil, 1500, 1900) compared nil against a number and raised,
which in this project is a blank dashboard with no message. The module's
own header promises nothing raises, and is_day() already guards the same
case, so the inconsistency was the bug.
Not reachable from the widget as written: it passes os.time(), and
parse() refuses a response without sunrise and sunset, so no caller can
currently produce the failing combination. Fixed anyway, because the
contract is what future callers will rely on and the fix is one word.
The test file also now says why the codepoint VALUES carry no assertion:
comparing M.ICON.snow against a literal would only prove the escape was
typed twice. Whether E31A draws a snow cloud is what the glyph sheet is
for, and mutation testing confirms the assertions cannot see it.
Found by code review. The same fix is applied to the plan, so Tasks 2-5
inherit the guarded version.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/weather.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/weather.lua b/lib/weather.lua index 4eab3ac..0b4b1b7 100644 --- a/lib/weather.lua +++ b/lib/weather.lua @@ -41,8 +41,12 @@ M.ICON = { -- face for the conditions that have both. function M.icon(id, now, sunrise, sunset) if type(id) ~= 'number' then return M.ICON.unknown end + -- `now` is guarded alongside sunrise and sunset, not just them: comparing a + -- nil now against a number raises, and a raise here is a blank dashboard. + -- Missing any of the three means the sun is unknown, so the day face is + -- drawn, which is what is_day() falls back to as well. local day = true - if sunrise and sunset then day = (now >= sunrise and now <= sunset) end + if now and sunrise and sunset then day = (now >= sunrise and now <= sunset) end local function pick(d, n) return day and d or n end if id <= 232 then return pick(M.ICON.thunder_day, M.ICON.thunder_night) |
