mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 22:34:09 +02:00
Improved errors for generic instantiation
This commit is contained in:
parent
2d4cc6d86e
commit
da563ee14b
1 changed files with 16 additions and 10 deletions
|
@ -6744,21 +6744,27 @@ bool BfExprEvaluator::CheckGenericCtor(BfGenericParamType* genericParamType, BfR
|
||||||
auto genericConstraint = mModule->GetGenericParamInstance(genericParamType);
|
auto genericConstraint = mModule->GetGenericParamInstance(genericParamType);
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
if ((genericConstraint->mGenericParamFlags & BfGenericParamFlag_New) == 0)
|
|
||||||
{
|
|
||||||
mModule->Fail(StrFormat("Must add 'where %s : new' constraint to generic parameter to instantiate type", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
if ((genericConstraint->mGenericParamFlags & BfGenericParamFlag_Struct) == 0)
|
|
||||||
{
|
|
||||||
mModule->Fail(StrFormat("Must add 'where %s : struct' constraint to generic parameter to instantiate type without allocator", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
if ((argValues.mArguments != NULL) && (argValues.mArguments->size() != 0))
|
if ((argValues.mArguments != NULL) && (argValues.mArguments->size() != 0))
|
||||||
{
|
{
|
||||||
mModule->Fail(StrFormat("Only default parameterless constructors can be called on generic argument '%s'", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
mModule->Fail(StrFormat("Only default parameterless constructors can be called on generic argument '%s'", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
else if ((genericConstraint->mGenericParamFlags & (BfGenericParamFlag_New | BfGenericParamFlag_Struct)) == 0)
|
||||||
|
{
|
||||||
|
mModule->Fail(StrFormat("Must add 'where %s : new, struct' constraint to generic parameter to instantiate type", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
else if ((genericConstraint->mGenericParamFlags & BfGenericParamFlag_New) == 0)
|
||||||
|
{
|
||||||
|
mModule->Fail(StrFormat("Must add 'where %s : new' constraint to generic parameter to instantiate type", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
else if ((genericConstraint->mGenericParamFlags & BfGenericParamFlag_Struct) == 0)
|
||||||
|
{
|
||||||
|
mModule->Fail(StrFormat("Must add 'where %s : struct' constraint to generic parameter to instantiate type without allocator", genericConstraint->GetGenericParamDef()->mName.c_str()), targetSrc);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue