Redefine `_VERSION` for Luau to include version number.
https://github.com/khvzak/mlua/discussions/228
This commit is contained in:
parent
6e95386f30
commit
c88417a3b6
|
@ -22,6 +22,12 @@ impl Lua {
|
|||
globals.raw_set("require", self.create_function(lua_require)?)?;
|
||||
globals.raw_set("vector", self.create_c_function(lua_vector)?)?;
|
||||
|
||||
// Set `_VERSION` global to include version number
|
||||
// The environment variable `LUAU_VERSION` set by the build script
|
||||
if let Some(version) = option_env!("LUAU_VERSION") {
|
||||
globals.raw_set("_VERSION", format!("Luau {version}"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,7 +276,10 @@ fn test_error() -> Result<()> {
|
|||
end, 3)
|
||||
|
||||
local function handler(err)
|
||||
if string.match(_VERSION, ' 5%.1$') or string.match(_VERSION, ' 5%.2$') or _VERSION == "Luau" then
|
||||
if string.match(_VERSION, " 5%.1$")
|
||||
or string.match(_VERSION, " 5%.2$")
|
||||
or string.match(_VERSION, "Luau")
|
||||
then
|
||||
-- Special case for Lua 5.1/5.2 and Luau
|
||||
local caps = string.match(err, ': (%d+)$')
|
||||
if caps then
|
||||
|
|
Loading…
Reference in New Issue