mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed crash attempting to bind function to const
This commit is contained in:
parent
3864a8896b
commit
7ca654aab1
3 changed files with 31 additions and 2 deletions
|
@ -6805,7 +6805,8 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
|
|||
{
|
||||
// We're attempting to directly invoke a non-virtual interface method, this will happen during the unspecialized pass
|
||||
// OR if we had an error and didn't find an implementing member in the actual target
|
||||
if ((!mModule->mCurMethodInstance->mIsUnspecialized) && (!mModule->mCurTypeInstance->IsInterface()))
|
||||
if (((mModule->mCurMethodInstance == NULL) || (!mModule->mCurMethodInstance->mIsUnspecialized)) &&
|
||||
(!mModule->mCurTypeInstance->IsInterface()))
|
||||
mModule->AssertErrorState();
|
||||
|
||||
if (returnType->IsInterface())
|
||||
|
|
|
@ -13093,7 +13093,7 @@ BfIRValue BfModule::CastToFunction(BfAstNode* srcNode, const BfTypedValue& targe
|
|||
{
|
||||
if ((!methodInstance->mIsUnspecialized) && (HasCompiledOutput()))
|
||||
AssertErrorState();
|
||||
return GetDefaultValue(dataType);
|
||||
return GetDefaultTypedValue(dataType, false, BfDefaultValueKind_Value).mValue;
|
||||
}
|
||||
bindFuncVal = methodRefMethod.mFunc;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,31 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
interface ITest
|
||||
{
|
||||
static void Func();
|
||||
}
|
||||
|
||||
class ClassC<T> where T : ITest
|
||||
{
|
||||
static function void() func = => T.Func;
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
class Zoop : ITest
|
||||
{
|
||||
public static int sVal;
|
||||
|
||||
public static void Func()
|
||||
{
|
||||
sVal = 123;
|
||||
}
|
||||
}
|
||||
|
||||
public static int UseFunc0<T>(function int (T this, float f) func, T a, float b)
|
||||
{
|
||||
return func(a, b);
|
||||
|
@ -226,6 +251,9 @@ namespace Tests
|
|||
});
|
||||
|
||||
StructCRepr.Test();
|
||||
|
||||
ClassC<Zoop>.Test();
|
||||
Test.Assert(Zoop.sVal == 123);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue