From db5351e898dee7d8387322b2c7ae2a7297501865 Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Fri, 26 Apr 2024 14:14:36 +1000 Subject: [PATCH] fixed typo in class auto-generation and included call site in auto-generated class name (id often useless) --- class.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/class.lua b/class.lua index a7e8105..4e5a081 100644 --- a/class.lua +++ b/class.lua @@ -64,7 +64,17 @@ local function class(config) config = config or {} local extends = config.extends local implements = config.implements - local name = config.name or ("unnamed class %d)"):format(class_id) + local src_location = "call location not available" + if debug and debug.getinfo then + local dinfo = debug.getinfo(2) + local src = dinfo.short_src + local line = dinfo.currentline + src_location = ("%s:%d"):format(src, line) + end + local name = config.name or ("unnamed class %d (%s)"):format( + class_id, + src_location + ) local c = {}