Require environment to be a Table instead of Value in Chunks.

In addition to that, `AsChunk::env()` renamed to `AsChunk::environment()`.
This commit is contained in:
Alex Orlenko
2023-06-02 23:59:16 +01:00
parent c905a34b1d
commit 9785722d61
3 changed files with 26 additions and 22 deletions
+4 -4
View File
@@ -1319,7 +1319,7 @@ impl Lua {
Chunk {
lua: self,
name: chunk.name().unwrap_or_else(|| caller.to_string()),
env: chunk.env(self),
env: chunk.environment(self),
mode: chunk.mode(),
source: chunk.source(),
#[cfg(feature = "luau")]
@@ -1330,7 +1330,7 @@ impl Lua {
pub(crate) fn load_chunk<'lua>(
&'lua self,
name: Option<&CStr>,
env: Value<'lua>,
env: Option<Table>,
mode: Option<ChunkMode>,
source: &[u8],
) -> Result<Function<'lua>> {
@@ -1353,8 +1353,8 @@ impl Lua {
mode_str,
) {
ffi::LUA_OK => {
if env != Value::Nil {
self.push_value(env)?;
if let Some(env) = env {
self.push_ref(&env.0);
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
ffi::lua_setupvalue(state, -2, 1);
#[cfg(any(feature = "lua51", feature = "luajit", feature = "luau"))]