feat(rules): add no-pow-bitmask rule for Lua 5.1 float issue #70

Closed
opened 2026-05-25 19:59:19 +02:00 by michael · 1 comment
Owner

Goal

Add rule to detect 2^ used for bitmask or integer arithmetic in Lua 5.1.
2^ always produces a float in Lua 5.1 -- using it for bitmasks or
integer operations can give wrong results.

Rule

no-pow-bitmask:
primitive: pattern
pattern: "2^"
file_pattern: "*.lua"
severity: warn
message: "{file}: 2^ found -- produces float in Lua 5.1, use integer arithmetic for bitmasks"

Known occurrences

  • daw-lua-net/ip_utils.lua (create_mask)
  • furt/src/smtp.lua (base64 encode/decode)
  • All ip_utils.lua copies in submodules

Notes

If false positives appear the rule can be refined or excluded per file.
Belongs in daw-code pack.

## Goal Add rule to detect 2^ used for bitmask or integer arithmetic in Lua 5.1. 2^ always produces a float in Lua 5.1 -- using it for bitmasks or integer operations can give wrong results. ## Rule no-pow-bitmask: primitive: pattern pattern: "2^" file_pattern: "*.lua" severity: warn message: "{file}: 2^ found -- produces float in Lua 5.1, use integer arithmetic for bitmasks" ## Known occurrences - daw-lua-net/ip_utils.lua (create_mask) - furt/src/smtp.lua (base64 encode/decode) - All ip_utils.lua copies in submodules ## Notes If false positives appear the rule can be refined or excluded per file. Belongs in daw-code pack.
Author
Owner

Implemented: no-pow-bitmask added to daw-lua-code pack.

Hit confirmed in daw-lua-net/ip_utils.lua:27 as expected. No false positives in fragjan itself.

Implemented: no-pow-bitmask added to daw-lua-code pack. Hit confirmed in daw-lua-net/ip_utils.lua:27 as expected. No false positives in fragjan itself.
michael 2026-05-26 16:27:31 +02:00
michael added this to the Basic Version milestone 2026-05-30 16:04:44 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#70
No description provided.