Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change preprocessor duplicate error to warning #2869

Merged
merged 2 commits into from
Nov 23, 2023
Merged
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
6 changes: 5 additions & 1 deletion lua/entities/gmod_wire_expression2/base/preprocessor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@

local ret, count, pos, found = {}, 0, 1
repeat
found = line:find((isinput or isoutput) and '[#"\\A-Z]' or '[#"\\]', pos)

Check warning on line 76 in lua/entities/gmod_wire_expression2/base/preprocessor.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
if found then -- We found something
local char = line:sub(found, found)
if (isinput or isoutput) and char:match("[A-Z]") ~= nil then -- we found the start of an input/output variable definition

Check warning on line 79 in lua/entities/gmod_wire_expression2/base/preprocessor.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'
local varname, endpos = line:match("^([A-Z][A-Za-z0-9_]*)()",found)
count = count + 1
ret[count] = {type = isinput and "inputs" or "outputs", name=varname, pos=found, blockcomment = {}}
Expand Down Expand Up @@ -200,7 +200,11 @@

for i, key in ipairs(retval[1]) do
if ports[3][key] then
self:Error("Directive (@" .. name .. ") contains multiple definitions of the same variable", columns[i])
if ports[3][key] ~= retval[2][i] then
self:Error("Directive (@" .. name .. ") contains multiple definitions of the same variable with differing types", columns[i])
else
self:Warning("Directive (@" .. name .. ") contains multiple definitions of the same variable", columns[i])
end
else
local index = #ports[1] + 1
ports[1][index] = key -- Index: Name
Expand Down Expand Up @@ -396,7 +400,7 @@
if not i then
-- no -> malformed variable name
self:Error("Variable name (" .. E2Lib.limitString(key, 10) .. ") must start with an uppercase letter", column)
goto cont

Check warning on line 403 in lua/entities/gmod_wire_expression2/base/preprocessor.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
-- yes -> add all variables.
for column2, var in namestring:gmatch("()([^,]+)") do
Expand Down Expand Up @@ -433,7 +437,7 @@

if vtype ~= vtype:lower() then
self:Error("Variable type [" .. E2Lib.limitString(vtype, 10) .. "] must be lowercase", column + i + 1)
goto cont

Check warning on line 440 in lua/entities/gmod_wire_expression2/base/preprocessor.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 vtype == "number" then
vtype = "normal"
elseif vtype == "normal" then
Expand All @@ -445,7 +449,7 @@
else
-- invalid -> raise an error
self:Error("Variable declaration (" .. E2Lib.limitString(key, 10) .. ") contains invalid characters", column + i)
goto cont

Check warning on line 452 in lua/entities/gmod_wire_expression2/base/preprocessor.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.
end

-- fill in the missing types
Expand Down
Loading