Skip to content

Commit b86ccd5

Browse files
committed
Use fusion.util.unpack instead of a ternary
Files changed: - fusion/core/compilers/source.lua - fusion/stdlib/functiona.lua - fusion/stdlib/iterable.lua - fusion/stdlib/table.lua - spec/class_spec.lua
1 parent 8e69ba9 commit b86ccd5

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

fusion/core/compilers/source.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44
local parser = require("fusion.core.parser")
55
local lfs = require("lfs")
6-
local unpack = unpack or table.unpack -- luacheck: ignore 113 143
6+
local unpack = require("fusion.util").unpack
77

88
local compiler = {}
99
local handlers = {}
1010

1111
--- Initialize a compiler state
12-
function compiler:new()
13-
self = setmetatable({}, {__index = compiler})
14-
self.indent = 0
15-
self.last_node = {}
16-
return self
12+
function compiler:new() -- luacheck: ignore 212
13+
local new_self = setmetatable({}, {__index = compiler})
14+
new_self.indent = 0
15+
new_self.last_node = {}
16+
return new_self
1717
end
1818

1919
--- Transform a node using the registered handler.
@@ -110,7 +110,7 @@ function compiler:transform_class_function(node)
110110
}
111111
end
112112

113-
handlers['re'] = function(self, node)
113+
handlers['re'] = function(self, node) -- luacheck: ignore 212
114114
return 're.compile(' .. ("%q"):format(node[1]) .. ')'
115115
end
116116

@@ -222,11 +222,11 @@ handlers['table'] = function(self, node)
222222
return table.concat(output, "\n")
223223
end
224224

225-
handlers['boolean'] = function(self, node)
225+
handlers['boolean'] = function(self, node) -- luacheck: ignore 212
226226
return tostring(node[1])
227227
end
228228

229-
handlers['break'] = function(self, node)
229+
handlers['break'] = function(self, node) -- luacheck: ignore 212
230230
return node.type
231231
end
232232

@@ -464,7 +464,7 @@ handlers['expression'] = function(self, node)
464464
end
465465
end
466466

467-
handlers['number'] = function(self, node)
467+
handlers['number'] = function(self, node) -- luacheck: ignore 212
468468
local is_negative = node.is_negative and "-" or ""
469469
if node.base == "10" then
470470
if math.floor(node[1]) == node[1] then
@@ -593,15 +593,15 @@ handlers['variable'] = function(self, node)
593593
return table.concat(name)
594594
end
595595

596-
handlers['sqstring'] = function(self, node)
596+
handlers['sqstring'] = function(self, node) -- luacheck: ignore 212
597597
return ("%q"):format(node[1]:gsub("\\", "\\\\")) -- \ is ignored in '' strings
598598
end
599599

600-
handlers['dqstring'] = function(self, node)
600+
handlers['dqstring'] = function(self, node) -- luacheck: ignore 212
601601
return ('"%s"'):format(node[1])
602602
end
603603

604-
handlers['blstring'] = function(self, node)
604+
handlers['blstring'] = function(self, node) -- luacheck: ignore 212
605605
local eq = ("="):rep(#node.eq)
606606
return ("[%s[%s]%s]"):format(eq, node[1], eq)
607607
end

fusion/stdlib/functional.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- Module for "functional" iterators and functions.
22
-- @module fusion.stdlib.functional
3-
local unpack = unpack or table.unpack -- luacheck: ignore 113 143
3+
local unpack = require("fusion.util").unpack
44

55
--- Iterate over a table's keys and values
66
-- @tparam table input

fusion/stdlib/iterable.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
-- @module fusion.stdlib.iterative
33
local fnl = require("fusion.stdlib.functional")
44
local table = require("fusion.stdlib.table")
5-
6-
local unpack = unpack or table.unpack -- luacheck: ignore 113
5+
local unpack = require("fusion.util").unpack
76

87
local iter, mk_gen = fnl._iter, fnl._mk_gen
98

fusion/stdlib/table.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ function table.slice(t, start, stop)
4848
end)
4949
end
5050

51-
table.unpack = unpack or table.unpack -- luacheck: ignore 113 143
51+
table.unpack = require("fusion.util").unpack
5252

5353
return table

spec/class_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local class = require("fusion.stdlib.class")
2+
local unpack = require("fusion.util").unpack
23

3-
local unpack = unpack or table.unpack -- luacheck: ignore 113 143
44
describe("class", function()
55
it("can make a simple class", function()
66
local x = class({}, {}, "Test")

0 commit comments

Comments
 (0)