From ecc6796b0ddb0c332268de81083d163b086a5832 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Sun, 10 May 2026 15:46:35 +0200 Subject: [PATCH] fix(audit-M1): tile_at 3-arg form accepts nil map_id with current_map fallback --- init.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 8249604..4f55977 100644 --- a/init.lua +++ b/init.lua @@ -169,16 +169,18 @@ function M.tile_size(map_id) return map_registry[id].tile_size end --- Arity-flex sugar: tile_at(tx, ty) uses current_map_id; tile_at(map_id, tx, ty) is explicit. +-- Arity-flex sugar: tile_at(tx, ty) uses current_map_id; tile_at(map_id, tx, ty) +-- is explicit. Both forms accept nil map_id and fall back to current_map_id. function M.tile_at(a, b, c) local map_id, tx, ty if c == nil then map_id, tx, ty = current_map_id, a, b - if not map_id then - error("maps.tile_at: no current map; call set_current() first or pass map_id") - end else map_id, tx, ty = a, b, c + if map_id == nil then map_id = current_map_id end + end + if not map_id then + error("maps.tile_at: no current map; call set_current() first or pass map_id") end local m = map_registry[map_id] if not m then