Skip to content

Commit a201ecb

Browse files
authored
backward compatibility with string calls and empty e2 return type (#3630)
* backward compatibility with string calls and empty e2, fix issue mention in #2841 * add test script for #2841 issue
1 parent 41f15b4 commit a201ecb

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

  • data_static/expression2/tests/regressions
  • lua/entities/gmod_wire_expression2/base
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## SHOULD_PASS:EXECUTE
2+
3+
function number test() {
4+
return 1
5+
}
6+
7+
"test"()

lua/entities/gmod_wire_expression2/base/compiler.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,7 @@ local CompileVisitors = {
18321832
local fn = state.funcs[sig] or state.funcs[meta_sig]
18331833
if fn then -- first check if user defined any functions that match signature
18341834
local r = state.funcs_ret[sig] or state.funcs_ret[meta_sig]
1835-
if r ~= ret_type then
1835+
if r ~= ret_type and not (ret_type == nil or r == "") then
18361836
state:forceThrow( "Mismatching return types. Got " .. (r or "void") .. ", expected " .. (ret_type or "void"))
18371837
end
18381838

@@ -1841,7 +1841,7 @@ local CompileVisitors = {
18411841
fn = wire_expression2_funcs[sig] or wire_expression2_funcs[meta_sig]
18421842
if fn then
18431843
local r = fn[2]
1844-
if r ~= ret_type and not (ret_type == nil and r == "") then
1844+
if r ~= ret_type and not (ret_type == nil or r == "") then
18451845
state:forceThrow( "Mismatching return types. Got " .. (r or "void") .. ", expected " .. (ret_type or "void"))
18461846
end
18471847

@@ -2132,4 +2132,4 @@ function Compiler:Process(ast)
21322132
end
21332133

21342134
return self:CompileStmt(ast)
2135-
end
2135+
end

0 commit comments

Comments
 (0)