diff --git a/data_static/expression2/tests/regressions/2841.txt b/data_static/expression2/tests/regressions/2841.txt new file mode 100644 index 0000000000..8676518808 --- /dev/null +++ b/data_static/expression2/tests/regressions/2841.txt @@ -0,0 +1,7 @@ +## SHOULD_PASS:EXECUTE + +function number test() { + return 1 +} + +"test"() diff --git a/lua/entities/gmod_wire_expression2/base/compiler.lua b/lua/entities/gmod_wire_expression2/base/compiler.lua index a4597854ae..b9ff290753 100644 --- a/lua/entities/gmod_wire_expression2/base/compiler.lua +++ b/lua/entities/gmod_wire_expression2/base/compiler.lua @@ -1832,7 +1832,7 @@ local CompileVisitors = { 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 @@ -1841,7 +1841,7 @@ local CompileVisitors = { 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 @@ -2132,4 +2132,4 @@ function Compiler:Process(ast) end return self:CompileStmt(ast) -end \ No newline at end of file +end