diff --git a/spec/inputs/test/format_spec.yue b/spec/inputs/test/format_spec.yue index 5076445..cbd9d22 100644 --- a/spec/inputs/test/format_spec.yue +++ b/spec/inputs/test/format_spec.yue @@ -50,6 +50,7 @@ files = [ "spec/inputs/test/table_spreading_spec.yue" "spec/inputs/test/loops_spec.yue" "spec/inputs/test/format_spec.yue" + "spec/inputs/upvalue_func.yue" "spec/inputs/unicode/macro_export.yue" "spec/inputs/unicode/attrib.yue" "spec/inputs/unicode/macro.yue" diff --git a/spec/inputs/upvalue_func.yue b/spec/inputs/upvalue_func.yue index a4155da..159be76 100644 --- a/spec/inputs/upvalue_func.yue +++ b/spec/inputs/upvalue_func.yue @@ -205,3 +205,21 @@ GameEngine\schedule (deltaTime) -> -- closure 1 UpdateScoreText "Score: #{value}" -- value is captured by closure 2 "continue" +-- test cases from issue +do + buff_strength = (char, item) -> + item.buffer.strength? char.stats.strength?::ref() + + exe_func = (func, env) -> + ok, ... = try + debug_env_before(env) + func(env) + debug_env_after(env) + catch ex + -- accessing ex and error + error ex + return ex + if ok + return ... + else + os.exit(1) diff --git a/spec/outputs/test/format_spec.lua b/spec/outputs/test/format_spec.lua index b12fb04..33a85f2 100644 --- a/spec/outputs/test/format_spec.lua +++ b/spec/outputs/test/format_spec.lua @@ -50,6 +50,7 @@ local files = { "spec/inputs/test/table_spreading_spec.yue", "spec/inputs/test/loops_spec.yue", "spec/inputs/test/format_spec.yue", + "spec/inputs/upvalue_func.yue", "spec/inputs/unicode/macro_export.yue", "spec/inputs/unicode/attrib.yue", "spec/inputs/unicode/macro.yue", diff --git a/spec/outputs/upvalue_func.lua b/spec/outputs/upvalue_func.lua index 125d75f..5768d2d 100644 --- a/spec/outputs/upvalue_func.lua +++ b/spec/outputs/upvalue_func.lua @@ -486,7 +486,7 @@ GameEngine:schedule(function(deltaTime) local value = 123 return func(_anon_func_27(UpdateScoreText, tostring, value)) end) -return GameEngine:schedule(function(deltaTime) +GameEngine:schedule(function(deltaTime) local value = 123 return func((function() if value > 200 then @@ -500,3 +500,44 @@ return GameEngine:schedule(function(deltaTime) end end)()) end) +local _anon_func_28 = function(char) + local _obj_0 = char.stats.strength + if _obj_0 ~= nil then + return _obj_0:ref() + end + return nil +end +local _anon_func_29 = function(os, _arg_0, ...) + do + local ok = _arg_0 + if ok then + return ... + else + return os.exit(1) + end + end +end +local _anon_func_30 = function(debug_env_after, debug_env_before, env, func) + do + debug_env_before(env) + func(env) + return debug_env_after(env) + end +end +do + local buff_strength + buff_strength = function(char, item) + local _obj_0 = item.buffer.strength + if _obj_0 ~= nil then + return _obj_0(_anon_func_28(char)) + end + return nil + end + local exe_func + exe_func = function(func, env) + return _anon_func_29(os, xpcall(_anon_func_30, function(ex) + error(ex) + return ex + end, debug_env_after, debug_env_before, env, func)) + end +end