The following ZScript will make GZDoom produce an error message:
Code: Select all
class TestA
{
}
class TestB : TestA
{
static TestB Create()
{
return new ("TestB");
}
}
class Test
{
TestA GetTest()
{
return TestB.Create();
}
}
Code: Select all
Return type Pointer<Class<TestA>> mismatch with Pointer<Class<TestB>>
Script error, "zscript.txt:ZSCRIPT" line 17:
Return type mismatch
- Replace TestB.Create() with new("TestB"). Interestingly enough, this doesn't produce any errors, though it is not an ideal solution if the class needs to do special initialization (which the class itself should be responsible for).
- Cast the return expression to TestA. This also fixes the error.
Tested on: GZDoom 3.6.0, g3.7pre-182-gb1d35eb0b