Fix incorrectly deduced type for function call

We were incorrectly deducing the internal type code T_USER when it
should have been T_UNKNOWN (or the code for the actual return type
but currently SWIG can't deduce the return type of a function call).

Bug introduced in 4.2.0 by b5ca500b40.

Fixes #2783
This commit is contained in:
Olly Betts 2024-01-31 10:13:39 +13:00
parent e49db2e461
commit d6850a60fa
2 changed files with 12 additions and 0 deletions

View File

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.1 (in progress)
===========================
2024-01-31: olly
#2783 Fix incorrectly deduced type for function call. Regression
introduced in 4.2.0.
2024-01-27: wsfulton
[Python] Fix compilation error when wrapping two or more classes that
have the same friend operator overload when the classes are in a namespace.

View File

@ -6882,7 +6882,15 @@ exprcompound : expr PLUS expr {
}
$$.val = NewStringf("%s%s",qty,scanner_ccode);
Clear(scanner_ccode);
// Try to deduce the type - this could be a C++ "constructor
// cast" such as `double(4)` or a function call such as
// `some_func()`. In the latter case we get T_USER, but that
// is wrong so we map it to T_UNKNOWN until we can actually
// deduce the return type of a function call (which is
// complicated because the return type can vary between
// overloaded forms).
$$.type = SwigType_type(qty);
if ($$.type == T_USER) $$.type = T_UNKNOWN;
Delete(qty);
}
;