From 5497775534d20ba06ab9c13bc4db1c5bee877513 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 28 Jul 2023 11:53:04 +0800 Subject: fix xpcall usages in different Lua version. --- spec/generated/5.1/try_catch.lua | 71 ++++++++++++++++++++++++++++++++ spec/inputs/macro-export.yue | 50 ----------------------- spec/inputs/macro-teal.yue | 87 ---------------------------------------- spec/inputs/macro-todo.yue | 13 ------ spec/inputs/macro.yue | 4 +- spec/inputs/macro_export.yue | 50 +++++++++++++++++++++++ spec/inputs/macro_teal.yue | 87 ++++++++++++++++++++++++++++++++++++++++ spec/inputs/macro_todo.yue | 13 ++++++ spec/inputs/teal-lang.yue | 36 ----------------- spec/inputs/teal_lang.yue | 36 +++++++++++++++++ spec/inputs/try-catch.yue | 54 ------------------------- spec/inputs/try_catch.yue | 54 +++++++++++++++++++++++++ spec/outputs/teal-lang.lua | 49 ---------------------- spec/outputs/teal-lang.tl | 60 --------------------------- spec/outputs/teal_lang.lua | 49 ++++++++++++++++++++++ spec/outputs/teal_lang.tl | 60 +++++++++++++++++++++++++++ spec/outputs/try-catch.lua | 61 ---------------------------- spec/outputs/try_catch.lua | 61 ++++++++++++++++++++++++++++ 18 files changed, 483 insertions(+), 412 deletions(-) create mode 100644 spec/generated/5.1/try_catch.lua delete mode 100644 spec/inputs/macro-export.yue delete mode 100644 spec/inputs/macro-teal.yue delete mode 100644 spec/inputs/macro-todo.yue create mode 100644 spec/inputs/macro_export.yue create mode 100644 spec/inputs/macro_teal.yue create mode 100644 spec/inputs/macro_todo.yue delete mode 100644 spec/inputs/teal-lang.yue create mode 100644 spec/inputs/teal_lang.yue delete mode 100644 spec/inputs/try-catch.yue create mode 100644 spec/inputs/try_catch.yue delete mode 100644 spec/outputs/teal-lang.lua delete mode 100644 spec/outputs/teal-lang.tl create mode 100644 spec/outputs/teal_lang.lua create mode 100644 spec/outputs/teal_lang.tl delete mode 100644 spec/outputs/try-catch.lua create mode 100644 spec/outputs/try_catch.lua (limited to 'spec') diff --git a/spec/generated/5.1/try_catch.lua b/spec/generated/5.1/try_catch.lua new file mode 100644 index 0000000..577df16 --- /dev/null +++ b/spec/generated/5.1/try_catch.lua @@ -0,0 +1,71 @@ +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(err) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +do + local success, result = xpcall(function() + return func(1, 2, 3) + end, function(err) + return print(err) + end) + success, result = pcall(func, 1, 2, 3) +end +pcall(tb.func) +pcall(tb.func) +pcall(tb.func) +pcall((tb.func)) +pcall(((function() + local _base_0 = tb + local _fn_0 = _base_0.func + return _fn_0 and function(...) + return _fn_0(_base_0, ...) + end +end)()), 1, 2, 3) +pcall(tb.func, 1) +pcall(tb.func, 1) +if (xpcall(function() + return func(1) +end, function(err) + return print(err) +end)) then + print("OK") +end +if xpcall(function() + return func(1) +end, function(err) + return print(err) +end) then + print("OK") +end +do + do + local success, result = pcall(func, "abc", 123) + if success then + print(result) + end + end + local success, result = xpcall(function() + return func("abc", 123) + end, function(err) + return print(err) + end) + success, result = xpcall(function() + return func("abc", 123) + end, function(err) + return print(err) + end) + if success then + print(result) + end +end +return nil diff --git a/spec/inputs/macro-export.yue b/spec/inputs/macro-export.yue deleted file mode 100644 index ff0d273..0000000 --- a/spec/inputs/macro-export.yue +++ /dev/null @@ -1,50 +0,0 @@ -import "macro-todo" as $ - -import "macro-todo" as {$, :$todo} - -export macro config = (debugging = true)-> - global debugMode = debugging == "true" - global debugMacro = true - "" - -export macro showMacro = (name, res)-> - if debugMacro then " -do - txt = #{res} - print '[macro ' .. #{name} .. ']' - print txt - txt -" - else - res - -export macro asserts = (cond)-> - if debugMode - $showMacro "assert", "assert #{cond}" - else - "" - -export macro assert = (cond)-> - if debugMode - $showMacro "assert", "assert #{cond}" - else - "#{cond}" - -export macro copy = (src, dst, ...)-> - assert( - src != "_src_" and src != "_dst_" and dst != "_src_" and dst != "_dst_" - "copy targets can not be _src_ or _dst_" - ) - " -do - local _src_, _dst_ - with _dst_ = #{dst} - with _src_ = #{src} -#{table.concat for field in *{...} do " - _dst_.#{field} = _src_.#{field} -"}" - -$ -> - global debugMode = true - global debugMacro = true - diff --git a/spec/inputs/macro-teal.yue b/spec/inputs/macro-teal.yue deleted file mode 100644 index a443614..0000000 --- a/spec/inputs/macro-teal.yue +++ /dev/null @@ -1,87 +0,0 @@ -$ -> - import "yue" as {:options} - if options.tl_enabled - options.target_extension = "tl" - package.path ..= ";./spec/lib/?.lua" - -macro to_lua = (code)-> - "require('yue').to_lua(#{code}, reserve_line_number:false, same_module:true)" - -macro trim = (name)-> - "if result = #{name}\\match '[\\'\"](.*)[\\'\"]' then result else #{name}" - -export macro local = (decl, value = nil)-> - import "yue" as {options:{:tl_enabled}} - name, type = ($trim decl)\match "(.-):(.*)" - if not (name and type) - error "invalid local varaible declaration for \"#{decl}\"" - value = $to_lua(value)\gsub "^return ", "" - code = if tl_enabled - "local #{name}:#{$trim type} = #{value}" - else - "local #{name} = #{value}" - { - :code - type: "text" - locals: {name} - } - -export macro function = (decl, value)-> - import "yue" as {options:{:tl_enabled}} - import "tl" - decl = $trim decl - name, type = decl\match "(.-)(%(.*)" - if not (name and type) - error "invalid function declaration for \"#{decl}\"" - tokens = tl.lex "function #{decl}" - _, node = tl.parse_program tokens,{},"macro-function" - args = table.concat [arg.tk for arg in *node[1].args],", " - value = "(#{args})#{value}" - code = if tl_enabled - value = $to_lua(value)\match "function%([^\n]*%)(.*)end" - "local function #{name}#{type}\n#{value}\nend" - else - value = $to_lua(value)\gsub "^return ", "" - "local #{name} = #{value}" - { - :code - type: "text" - locals: {name} - } - -export macro record = (name, decl)-> - import "yue" as {options:{:tl_enabled}} - code = if tl_enabled - "local record #{name} - #{decl} -end" - else - "local #{name} = {}" - { - :code - type: "text" - locals: {name} - } - -export macro method = (decl, value)-> - import "yue" as {options:{:tl_enabled}} - import "tl" - decl = $trim decl - tab, sym, func, type = decl\match "(.-)([%.:])(.-)(%(.*)" - if not (tab and sym and func and type) - error "invalid method declaration for \"#{decl}\"" - tokens = tl.lex "function #{decl}" - _, node = tl.parse_program tokens,{},"macro-function" - args = table.concat [arg.tk for arg in *node[1].args],", " - value = "(#{args})->#{value\match "[%-=]>(.*)"}" - code = if tl_enabled - value = $to_lua(value)\match "^return function%(.-%)\n(.*)end" - "function #{tab}#{sym}#{func}#{type}\n#{value}\nend" - else - value = $to_lua(value)\gsub "^return ", "" - "#{tab}.#{func} = #{value}" - { - :code - type: "text" - } - diff --git a/spec/inputs/macro-todo.yue b/spec/inputs/macro-todo.yue deleted file mode 100644 index 752c9cb..0000000 --- a/spec/inputs/macro-todo.yue +++ /dev/null @@ -1,13 +0,0 @@ -export macro todoInner = (module, line, msg)-> - print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" - { - code: "-- TODO#{msg and ': ' .. msg or ''}" - type: "lua" - } - -export macro todo = (msg)-> - if msg - "$todoInner $FILE, $LINE, #{msg}" - else - "$todoInner $FILE, $LINE" - diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index ac51d85..ae14f53 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue @@ -1,9 +1,9 @@ -import "macro-export" as { +import "macro_export" as { $, -- import all macros $config: $myconfig, -- rename macro $config to $myconfig } -import "macro-todo" as $ +import "macro_todo" as $ $asserts item == nil diff --git a/spec/inputs/macro_export.yue b/spec/inputs/macro_export.yue new file mode 100644 index 0000000..eec5848 --- /dev/null +++ b/spec/inputs/macro_export.yue @@ -0,0 +1,50 @@ +import "macro_todo" as $ + +import "macro_todo" as {$, :$todo} + +export macro config = (debugging = true)-> + global debugMode = debugging == "true" + global debugMacro = true + "" + +export macro showMacro = (name, res)-> + if debugMacro then " +do + txt = #{res} + print '[macro ' .. #{name} .. ']' + print txt + txt +" + else + res + +export macro asserts = (cond)-> + if debugMode + $showMacro "assert", "assert #{cond}" + else + "" + +export macro assert = (cond)-> + if debugMode + $showMacro "assert", "assert #{cond}" + else + "#{cond}" + +export macro copy = (src, dst, ...)-> + assert( + src != "_src_" and src != "_dst_" and dst != "_src_" and dst != "_dst_" + "copy targets can not be _src_ or _dst_" + ) + " +do + local _src_, _dst_ + with _dst_ = #{dst} + with _src_ = #{src} +#{table.concat for field in *{...} do " + _dst_.#{field} = _src_.#{field} +"}" + +$ -> + global debugMode = true + global debugMacro = true + diff --git a/spec/inputs/macro_teal.yue b/spec/inputs/macro_teal.yue new file mode 100644 index 0000000..a443614 --- /dev/null +++ b/spec/inputs/macro_teal.yue @@ -0,0 +1,87 @@ +$ -> + import "yue" as {:options} + if options.tl_enabled + options.target_extension = "tl" + package.path ..= ";./spec/lib/?.lua" + +macro to_lua = (code)-> + "require('yue').to_lua(#{code}, reserve_line_number:false, same_module:true)" + +macro trim = (name)-> + "if result = #{name}\\match '[\\'\"](.*)[\\'\"]' then result else #{name}" + +export macro local = (decl, value = nil)-> + import "yue" as {options:{:tl_enabled}} + name, type = ($trim decl)\match "(.-):(.*)" + if not (name and type) + error "invalid local varaible declaration for \"#{decl}\"" + value = $to_lua(value)\gsub "^return ", "" + code = if tl_enabled + "local #{name}:#{$trim type} = #{value}" + else + "local #{name} = #{value}" + { + :code + type: "text" + locals: {name} + } + +export macro function = (decl, value)-> + import "yue" as {options:{:tl_enabled}} + import "tl" + decl = $trim decl + name, type = decl\match "(.-)(%(.*)" + if not (name and type) + error "invalid function declaration for \"#{decl}\"" + tokens = tl.lex "function #{decl}" + _, node = tl.parse_program tokens,{},"macro-function" + args = table.concat [arg.tk for arg in *node[1].args],", " + value = "(#{args})#{value}" + code = if tl_enabled + value = $to_lua(value)\match "function%([^\n]*%)(.*)end" + "local function #{name}#{type}\n#{value}\nend" + else + value = $to_lua(value)\gsub "^return ", "" + "local #{name} = #{value}" + { + :code + type: "text" + locals: {name} + } + +export macro record = (name, decl)-> + import "yue" as {options:{:tl_enabled}} + code = if tl_enabled + "local record #{name} + #{decl} +end" + else + "local #{name} = {}" + { + :code + type: "text" + locals: {name} + } + +export macro method = (decl, value)-> + import "yue" as {options:{:tl_enabled}} + import "tl" + decl = $trim decl + tab, sym, func, type = decl\match "(.-)([%.:])(.-)(%(.*)" + if not (tab and sym and func and type) + error "invalid method declaration for \"#{decl}\"" + tokens = tl.lex "function #{decl}" + _, node = tl.parse_program tokens,{},"macro-function" + args = table.concat [arg.tk for arg in *node[1].args],", " + value = "(#{args})->#{value\match "[%-=]>(.*)"}" + code = if tl_enabled + value = $to_lua(value)\match "^return function%(.-%)\n(.*)end" + "function #{tab}#{sym}#{func}#{type}\n#{value}\nend" + else + value = $to_lua(value)\gsub "^return ", "" + "#{tab}.#{func} = #{value}" + { + :code + type: "text" + } + diff --git a/spec/inputs/macro_todo.yue b/spec/inputs/macro_todo.yue new file mode 100644 index 0000000..752c9cb --- /dev/null +++ b/spec/inputs/macro_todo.yue @@ -0,0 +1,13 @@ +export macro todoInner = (module, line, msg)-> + print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" + { + code: "-- TODO#{msg and ': ' .. msg or ''}" + type: "lua" + } + +export macro todo = (msg)-> + if msg + "$todoInner $FILE, $LINE, #{msg}" + else + "$todoInner $FILE, $LINE" + diff --git a/spec/inputs/teal-lang.yue b/spec/inputs/teal-lang.yue deleted file mode 100644 index b28c915..0000000 --- a/spec/inputs/teal-lang.yue +++ /dev/null @@ -1,36 +0,0 @@ -import "macro-teal" as $ - -$local "a:{string:number}", {value:123} -$local "b:number", a.value - -$function "add(a:number, b:number):number", -> a + b - -s = add(a.value, b) -print(s) - -$record Point, - x: number - y: number - -$method "Point.new(x:number, y:number):Point", -> - $local "point:Point", setmetatable {}, __index: Point - point.x = x or 0 - point.y = y or 0 - point - -$method "Point:move(dx:number, dy:number)", -> - @x += dx - @y += dy - -$local "p:Point", Point.new 100, 100 - -p\move 50, 50 - -$function "filter(tab:{string}, handler:function(item:string):boolean):{string}", -> - [item for item in *tab when handler item] - -$function "cond(item:string):boolean", -> item ~= "a" - -res = filter {"a", "b", "c", "a"}, cond -for s in *res - print s diff --git a/spec/inputs/teal_lang.yue b/spec/inputs/teal_lang.yue new file mode 100644 index 0000000..e01682f --- /dev/null +++ b/spec/inputs/teal_lang.yue @@ -0,0 +1,36 @@ +import "macro_teal" as $ + +$local "a:{string:number}", {value:123} +$local "b:number", a.value + +$function "add(a:number, b:number):number", -> a + b + +s = add(a.value, b) +print(s) + +$record Point, + x: number + y: number + +$method "Point.new(x:number, y:number):Point", -> + $local "point:Point", setmetatable {}, __index: Point + point.x = x or 0 + point.y = y or 0 + point + +$method "Point:move(dx:number, dy:number)", -> + @x += dx + @y += dy + +$local "p:Point", Point.new 100, 100 + +p\move 50, 50 + +$function "filter(tab:{string}, handler:function(item:string):boolean):{string}", -> + [item for item in *tab when handler item] + +$function "cond(item:string):boolean", -> item ~= "a" + +res = filter {"a", "b", "c", "a"}, cond +for s in *res + print s diff --git a/spec/inputs/try-catch.yue b/spec/inputs/try-catch.yue deleted file mode 100644 index e38cbef..0000000 --- a/spec/inputs/try-catch.yue +++ /dev/null @@ -1,54 +0,0 @@ -try - func 1, 2, 3 -catch err - print err - -try func 1, 2, 3 -catch err - print err - -try - print "trying" - func 1, 2, 3 - -do - success, result = try - func 1, 2, 3 - catch err - print err - - success, result = try func 1, 2, 3 - -try tb.func -try tb.func! -try tb.func() -try (tb.func!) -try (tb\func(1, 2, 3)) - -try tb.func 1 -try tb.func(1) - -if (try func 1 -catch err - print err) - print "OK" - -if try (func 1) -catch err - print err - print "OK" - -do - if success, result = try func "abc", 123 - print result - - success, result = try func "abc", 123 - catch err - print err - - print result if success, result = try func "abc", 123 - catch err - print err - -nil - diff --git a/spec/inputs/try_catch.yue b/spec/inputs/try_catch.yue new file mode 100644 index 0000000..e38cbef --- /dev/null +++ b/spec/inputs/try_catch.yue @@ -0,0 +1,54 @@ +try + func 1, 2, 3 +catch err + print err + +try func 1, 2, 3 +catch err + print err + +try + print "trying" + func 1, 2, 3 + +do + success, result = try + func 1, 2, 3 + catch err + print err + + success, result = try func 1, 2, 3 + +try tb.func +try tb.func! +try tb.func() +try (tb.func!) +try (tb\func(1, 2, 3)) + +try tb.func 1 +try tb.func(1) + +if (try func 1 +catch err + print err) + print "OK" + +if try (func 1) +catch err + print err + print "OK" + +do + if success, result = try func "abc", 123 + print result + + success, result = try func "abc", 123 + catch err + print err + + print result if success, result = try func "abc", 123 + catch err + print err + +nil + diff --git a/spec/outputs/teal-lang.lua b/spec/outputs/teal-lang.lua deleted file mode 100644 index 28ba6f8..0000000 --- a/spec/outputs/teal-lang.lua +++ /dev/null @@ -1,49 +0,0 @@ -local a = { - value = 123 -} -local b = a.value -local add = function(a, b) - return a + b -end -local s = add(a.value, b) -print(s) -local Point = {} -Point.new = function(x, y) -local point = setmetatable({ }, { - __index = Point -}) - point.x = x or 0 - point.y = y or 0 - return point -end -Point.move = function(self, dx, dy) - self.x = self.x + dx - self.y = self.y + dy -end -local p = Point.new(100, 100) -p:move(50, 50) -local filter = function(tab, handler) - local _accum_0 = { } - local _len_0 = 1 - for _index_0 = 1, #tab do - local item = tab[_index_0] - if handler(item) then - _accum_0[_len_0] = item - _len_0 = _len_0 + 1 - end - end - return _accum_0 -end -local cond = function(item) - return item ~= "a" -end -local res = filter({ - "a", - "b", - "c", - "a" -}, cond) -for _index_0 = 1, #res do - local s = res[_index_0] - print(s) -end diff --git a/spec/outputs/teal-lang.tl b/spec/outputs/teal-lang.tl deleted file mode 100644 index 0dc25a1..0000000 --- a/spec/outputs/teal-lang.tl +++ /dev/null @@ -1,60 +0,0 @@ -local a:{string:number} = { - value = 123 -} -local b:number = a.value -local function add(a:number, b:number):number - - return a + b - -end -local s = add(a.value, b) -print(s) -local record Point - x: number - y: number -end -function Point.new(x:number, y:number):Point -local point:Point = setmetatable({ }, { - __index = Point -}) - point.x = x or 0 - point.y = y or 0 - return point - -end -function Point:move(dx:number, dy:number) - self.x = self.x + dx - self.y = self.y + dy - -end -local p:Point = Point.new(100, 100) -p:move(50, 50) -local function filter(tab:{string}, handler:function(item:string):boolean):{string} - - local _accum_0 = { } - local _len_0 = 1 - for _index_0 = 1, #tab do - local item = tab[_index_0] - if handler(item) then - _accum_0[_len_0] = item - _len_0 = _len_0 + 1 - end - end - return _accum_0 - -end -local function cond(item:string):boolean - - return item ~= "a" - -end -local res = filter({ - "a", - "b", - "c", - "a" -}, cond) -for _index_0 = 1, #res do - local s = res[_index_0] - print(s) -end diff --git a/spec/outputs/teal_lang.lua b/spec/outputs/teal_lang.lua new file mode 100644 index 0000000..28ba6f8 --- /dev/null +++ b/spec/outputs/teal_lang.lua @@ -0,0 +1,49 @@ +local a = { + value = 123 +} +local b = a.value +local add = function(a, b) + return a + b +end +local s = add(a.value, b) +print(s) +local Point = {} +Point.new = function(x, y) +local point = setmetatable({ }, { + __index = Point +}) + point.x = x or 0 + point.y = y or 0 + return point +end +Point.move = function(self, dx, dy) + self.x = self.x + dx + self.y = self.y + dy +end +local p = Point.new(100, 100) +p:move(50, 50) +local filter = function(tab, handler) + local _accum_0 = { } + local _len_0 = 1 + for _index_0 = 1, #tab do + local item = tab[_index_0] + if handler(item) then + _accum_0[_len_0] = item + _len_0 = _len_0 + 1 + end + end + return _accum_0 +end +local cond = function(item) + return item ~= "a" +end +local res = filter({ + "a", + "b", + "c", + "a" +}, cond) +for _index_0 = 1, #res do + local s = res[_index_0] + print(s) +end diff --git a/spec/outputs/teal_lang.tl b/spec/outputs/teal_lang.tl new file mode 100644 index 0000000..0dc25a1 --- /dev/null +++ b/spec/outputs/teal_lang.tl @@ -0,0 +1,60 @@ +local a:{string:number} = { + value = 123 +} +local b:number = a.value +local function add(a:number, b:number):number + + return a + b + +end +local s = add(a.value, b) +print(s) +local record Point + x: number + y: number +end +function Point.new(x:number, y:number):Point +local point:Point = setmetatable({ }, { + __index = Point +}) + point.x = x or 0 + point.y = y or 0 + return point + +end +function Point:move(dx:number, dy:number) + self.x = self.x + dx + self.y = self.y + dy + +end +local p:Point = Point.new(100, 100) +p:move(50, 50) +local function filter(tab:{string}, handler:function(item:string):boolean):{string} + + local _accum_0 = { } + local _len_0 = 1 + for _index_0 = 1, #tab do + local item = tab[_index_0] + if handler(item) then + _accum_0[_len_0] = item + _len_0 = _len_0 + 1 + end + end + return _accum_0 + +end +local function cond(item:string):boolean + + return item ~= "a" + +end +local res = filter({ + "a", + "b", + "c", + "a" +}, cond) +for _index_0 = 1, #res do + local s = res[_index_0] + print(s) +end diff --git a/spec/outputs/try-catch.lua b/spec/outputs/try-catch.lua deleted file mode 100644 index 129d412..0000000 --- a/spec/outputs/try-catch.lua +++ /dev/null @@ -1,61 +0,0 @@ -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(err) -end) -xpcall(func, function(err) - return print(err) -end, 1, 2, 3) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -do - local success, result = xpcall(function() - return func(1, 2, 3) - end, function(err) - return print(err) - end) - success, result = pcall(func, 1, 2, 3) -end -pcall(tb.func) -pcall(tb.func) -pcall(tb.func) -pcall((tb.func)) -pcall(((function() - local _base_0 = tb - local _fn_0 = _base_0.func - return _fn_0 and function(...) - return _fn_0(_base_0, ...) - end -end)()), 1, 2, 3) -pcall(tb.func, 1) -pcall(tb.func, 1) -if (xpcall(func, function(err) - return print(err) -end, 1)) then - print("OK") -end -if xpcall((func), function(err) - return print(err) -end, 1) then - print("OK") -end -do - do - local success, result = pcall(func, "abc", 123) - if success then - print(result) - end - end - local success, result = xpcall(func, function(err) - return print(err) - end, "abc", 123) - success, result = xpcall(func, function(err) - return print(err) - end, "abc", 123) - if success then - print(result) - end -end -return nil diff --git a/spec/outputs/try_catch.lua b/spec/outputs/try_catch.lua new file mode 100644 index 0000000..129d412 --- /dev/null +++ b/spec/outputs/try_catch.lua @@ -0,0 +1,61 @@ +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(err) +end) +xpcall(func, function(err) + return print(err) +end, 1, 2, 3) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +do + local success, result = xpcall(function() + return func(1, 2, 3) + end, function(err) + return print(err) + end) + success, result = pcall(func, 1, 2, 3) +end +pcall(tb.func) +pcall(tb.func) +pcall(tb.func) +pcall((tb.func)) +pcall(((function() + local _base_0 = tb + local _fn_0 = _base_0.func + return _fn_0 and function(...) + return _fn_0(_base_0, ...) + end +end)()), 1, 2, 3) +pcall(tb.func, 1) +pcall(tb.func, 1) +if (xpcall(func, function(err) + return print(err) +end, 1)) then + print("OK") +end +if xpcall((func), function(err) + return print(err) +end, 1) then + print("OK") +end +do + do + local success, result = pcall(func, "abc", 123) + if success then + print(result) + end + end + local success, result = xpcall(func, function(err) + return print(err) + end, "abc", 123) + success, result = xpcall(func, function(err) + return print(err) + end, "abc", 123) + if success then + print(result) + end +end +return nil -- cgit v1.2.3-55-g6feb