Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/entities/gmod_wire_expression2/base/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@

---@param data { [1]: Token<string>, [2]: Node, [3]: Node, [4]: Node?, [5]: Node } var start stop step block
[NodeVariant.For] = function (self, trace, data)
local var, start, stop, step = data[1], self:CompileExpr(data[2]), self:CompileExpr(data[3]), data[4] and self:CompileExpr(data[4]) or data[4]

Check warning on line 410 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: step

local block = self:Scope(function(scope)
scope.data.loop = true
Expand Down Expand Up @@ -586,9 +586,9 @@

if state.__break__ then
state.__break__ = false
goto exit

Check warning on line 589 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Goto"

Don't use labels and gotos unless you're jumping out of multiple loops.
elseif state.__return__ then -- Yes this should only be checked if the switch is inside a function, but I don't care enough about the performance of switch case to add another duplicated 30 lines to the file
goto exit

Check warning on line 591 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Goto"

Don't use labels and gotos unless you're jumping out of multiple loops.
else -- Fallthrough, run every case until break found.
for j = i + 1, ncases do
cases[j][2](state)
Expand Down Expand Up @@ -1047,9 +1047,9 @@
state.GlobalScope[var], state.GlobalScope.vclk[var] = val, true

if state.GlobalScope.lookup[val] then
state.GlobalScope.lookup[val][var] = true

Check warning on line 1050 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
else
state.GlobalScope.lookup[val] = { [var] = true }

Check warning on line 1052 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
end
else
Expand Down Expand Up @@ -1832,7 +1832,7 @@
local fn = state.funcs[sig] or state.funcs[meta_sig]
if fn then -- first check if user defined any functions that match signature
local r = state.funcs_ret[sig] or state.funcs_ret[meta_sig]
if r ~= ret_type then
if r ~= ret_type and not (ret_type == nil or r == "") then
state:forceThrow( "Mismatching return types. Got " .. (r or "void") .. ", expected " .. (ret_type or "void"))
end

Expand All @@ -1841,7 +1841,7 @@
fn = wire_expression2_funcs[sig] or wire_expression2_funcs[meta_sig]
if fn then
local r = fn[2]
if r ~= ret_type and not (ret_type == nil and r == "") then
if r ~= ret_type and not (ret_type == nil or r == "") then
state:forceThrow( "Mismatching return types. Got " .. (r or "void") .. ", expected " .. (ret_type or "void"))
end

Expand All @@ -1867,7 +1867,7 @@
if fn.attributes.legacy then
local largs = { [1] = {}, [nargs + 2] = arg_types }
for i = 1, nargs do
largs[i + 1] = { [1] = function() return rargs[i] end }

Check warning on line 1870 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
return fn[3](state, largs, arg_types)
elseif varsig == "array(...)" then -- Need this since can't enforce compile time argument type restrictions on string calls. Woop. Array creation should not be a function..
Expand All @@ -1875,11 +1875,11 @@
while i <= #arg_types do
local ty = arg_types[i]
if BLOCKED_ARRAY_TYPES[ty] then
table.remove(rargs, i)

Check warning on line 1878 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
table.remove(arg_types, i)
state:forceThrow("Cannot use type " .. ty .. " for argument #" .. i .. " in stringcall array creation")
else
i = i + 1

Check warning on line 1882 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
end
end
Expand All @@ -1892,7 +1892,7 @@
if fn then
for _, ty in ipairs(arg_types) do -- Just block them entirely. Current method of finding variadics wouldn't allow a proper solution that works with x<yz> types. Would need to rewrite all of this which I don't think is worth it when already nobody is going to use this functionality.
if BLOCKED_ARRAY_TYPES[ty] then
state:forceThrow("Cannot pass array into variadic array function")

Check warning on line 1895 in lua/entities/gmod_wire_expression2/base/compiler.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
end

Expand Down
Loading