From 45eb015fc25473329575235c72c607bd15ad27dc Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 26 Mar 2025 15:56:34 +0800 Subject: Fixed issue #201. --- src/yuescript/yue_compiler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index e3c9d31..a2a1864 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -75,7 +75,7 @@ static std::unordered_set Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.27.2"sv; +const std::string_view version = "0.27.3"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { @@ -4795,8 +4795,8 @@ private: auto varName = variableToString(ast_to(var)); auto closeVar = getUnusedName("_close_"sv); addToScope(closeVar); - getCloses.push_back(closeVar + "=assert "s + varName + "."s); - doCloses.push_front(closeVar + ' ' + varName); + getCloses.push_back(closeVar + "=if type("s + varName + ") in ['table', 'userdata'] then assert "s + varName + ".<> and "s + varName +"., \""s + "variable '"s + varName + "' got a non-closable value\" elseif "s + varName + " == nil then nil else error \""s + "variable '"s + varName + "' got a non-closable value\""); + doCloses.push_front(closeVar + "? "s + varName); } popScope(); auto okVar = getUnusedName("_ok_"sv); -- cgit v1.2.3-55-g6feb