Skip to content

fix(widget.cal): Lua 5.5 read-only for-loop variable - #568

Open
megvadulthangya wants to merge 1 commit into
lcpz:masterfrom
megvadulthangya:lua5.5-compatibility
Open

fix(widget.cal): Lua 5.5 read-only for-loop variable#568
megvadulthangya wants to merge 1 commit into
lcpz:masterfrom
megvadulthangya:lua5.5-compatibility

Conversation

@megvadulthangya

Copy link
Copy Markdown

Problem

In Lua 5.5, for-loop variables are now read-only (see Lua 5.5 changes).
The calendar widget (cal.lua) was reassigning the loop variable x inside the loop body, causing a crash:

attempt to assign to const variable 'x'

This prevented awesome from starting when built with Lua 5.5.

Fix

Inside cal.build, the loop variable x is now kept read-only; its formatted string representation is assigned to a separate local variable x_str instead.

for x = 1,mth_days do
    local strx
    if x == today then
        local x_str = x
        if x < 10 then x_str = " " .. x end
        strx = markup.bold(markup.color(cal.notification_preset.bg, cal.notification_preset.fg, x_str) .. " ")
    else
        strx = x
    end
    ...
end

This is the only line that required modification. No other files were changed.

Testing

  • ✅ Built awesome-git with Lua 5.5, started successfully with lain and powerarrow-dark theme.
  • ✅ The calendar widget displays correctly, both in the notification and the popup.
  • ✅ No regressions on Lua 5.4 or 5.3 (tested with awesome built against those versions).

Related

Replaces the previous (closed) PR which contained unnecessary changes.
This minimal fix addresses exactly the root cause as pointed out by @Aire-One.

…a 5.5

Lua 5.5 makes for-loop variables read-only, so reassigning the loop
variable `x` inside the calendar loop is now an error.
Use a separate local variable `x_str` for the formatted string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant