From 2cdf35e769dd904759d50a6589474d6a52605916 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 17 Jun 2025 19:02:44 -0300 Subject: rockspec: re-add deprecated function type(). Removing this broke the behavior of some luarocks.build plugins. LuaRocks does not have a stable public API, but since this function was returned as part of the function signature, we'll revert this as a deprecated function, to be removed in LuaRocks 4.0. Closes #1800. --- src/luarocks/rockspecs.lua | 16 +++++++++++++++- src/luarocks/rockspecs.tl | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index 8a1a528e..7f137b87 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua @@ -24,6 +24,19 @@ local vendored_build_type_set = { ["none"] = true, } +local rockspec_mt_funcs = {} + +local rockspec_mt = {} +rockspec_mt.__index = rockspec_mt_funcs + +function rockspec_mt_funcs.type() + util.warning("The function rockspec.type() is no longer " .. + "necessary and is now deprecated. Please update your " .. + "plugin to remove calls to this function.") + + return "rockspec" +end + @@ -181,7 +194,8 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) configure_paths(rockspec) end - return rockspec + + return setmetatable(rockspec, rockspec_mt) end return rockspecs diff --git a/src/luarocks/rockspecs.tl b/src/luarocks/rockspecs.tl index 9f12649c..7f31f786 100644 --- a/src/luarocks/rockspecs.tl +++ b/src/luarocks/rockspecs.tl @@ -24,6 +24,19 @@ local vendored_build_type_set: {string: boolean} = { ["none"] = true, } +local rockspec_mt_funcs = {} + +local rockspec_mt: metatable = {} +rockspec_mt.__index = rockspec_mt_funcs + +function rockspec_mt_funcs.type(): string + util.warning("The function rockspec.type() is no longer " .. + "necessary and is now deprecated. Please update your " .. + "plugin to remove calls to this function.") + + return "rockspec" +end + --- Perform platform-specific overrides on a table. -- Overrides values of table with the contents of the appropriate -- subset of its "platforms" field. The "platforms" field should @@ -181,7 +194,8 @@ function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, gl configure_paths(rockspec) end - return rockspec + -- TODO remove this on LuaRocks 4.0 + return setmetatable(rockspec, rockspec_mt) end return rockspecs -- cgit v1.2.3-55-g6feb