forked from Mirrors/openclonk
Incompatible type warnings work for parameters with type declarations
parent
55572720bc
commit
5fbac346d3
|
@ -1057,6 +1057,15 @@ C4V_Type C4AulParse::GetLastRetType(C4V_Type to)
|
|||
case AB_Not: case AB_LessThan: case AB_LessThanEqual: case AB_GreaterThan: case AB_GreaterThanEqual:
|
||||
case AB_Equal: case AB_NotEqual:
|
||||
from = C4V_Bool; break;
|
||||
case AB_DUP:
|
||||
{
|
||||
int pos = Fn->GetLastCode()->Par.i + iStack - 2 + Fn->VarNamed.iSize + Fn->GetParCount();
|
||||
if (pos < Fn->GetParCount())
|
||||
from = Fn->GetParType()[pos];
|
||||
else
|
||||
from = C4V_Any;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
from = C4V_Any; break;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "script/C4ScriptHost.h"
|
||||
#include "lib/C4Random.h"
|
||||
#include "object/C4DefList.h"
|
||||
#include "TestLog.h"
|
||||
|
||||
C4Value AulTest::RunCode(const char *code, bool wrap)
|
||||
{
|
||||
|
@ -129,3 +130,19 @@ TEST_F(AulTest, Vars)
|
|||
EXPECT_EQ(C4VInt(42), RunCode("var i = 21; i = i + i; return i;"));
|
||||
EXPECT_EQ(C4VInt(42), RunCode("var i = -42; i = Abs(i); return i;"));
|
||||
}
|
||||
|
||||
TEST_F(AulTest, Warnings)
|
||||
{
|
||||
LogMock log;
|
||||
EXPECT_CALL(log, DebugLog(testing::StartsWith("WARNING:"))).Times(3);
|
||||
EXPECT_EQ(C4Value(), RunCode("func Main(string s, object o, array a) { Sin(s); }", false));
|
||||
EXPECT_EQ(C4Value(), RunCode("func Main(string s, object o, array a) { Sin(o); }", false));
|
||||
EXPECT_EQ(C4Value(), RunCode("func Main(string s, object o, array a) { Sin(a); }", false));
|
||||
}
|
||||
|
||||
TEST_F(AulTest, NoWarnings)
|
||||
{
|
||||
LogMock log;
|
||||
EXPECT_CALL(log, DebugLog(testing::StartsWith("WARNING:"))).Times(0);
|
||||
EXPECT_EQ(C4Value(), RunCode("func Main(string s, object o, array a) { var x; Sin(x); }", false));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue