1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 22:34:09 +02:00

Added error for attempting to instantiate opaque attributes

This commit is contained in:
Brian Fiete 2025-01-24 06:53:49 -08:00
parent 9a9e12ea37
commit 6d474b31d9

View file

@ -12817,6 +12817,7 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
bool success = true; bool success = true;
int methodCheckCount = 0;
bool isFailurePass = false; bool isFailurePass = false;
for (int pass = 0; pass < 2; pass++) for (int pass = 0; pass < 2; pass++)
{ {
@ -12833,6 +12834,7 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
if ((!isFailurePass) && (!CheckProtection(checkMethod->mProtection, attrTypeInst->mTypeDef, false, false))) if ((!isFailurePass) && (!CheckProtection(checkMethod->mProtection, attrTypeInst->mTypeDef, false, false)))
continue; continue;
methodCheckCount++;
methodMatcher.CheckMethod(NULL, attrTypeInst, checkMethod, isFailurePass); methodMatcher.CheckMethod(NULL, attrTypeInst, checkMethod, isFailurePass);
} }
@ -12856,6 +12858,8 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
if (methodMatcher.mBestMethodDef == NULL) if (methodMatcher.mBestMethodDef == NULL)
{ {
if (methodCheckCount == 0)
Fail(StrFormat("No attribute constructors found for type '%s'", TypeToString(attrTypeInst).c_str()), attributesDirective);
AssertErrorState(); AssertErrorState();
continue; continue;
} }
@ -13351,7 +13355,7 @@ BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bo
return typedValue; return typedValue;
PopulateType(typedValue.mType); PopulateType(typedValue.mType);
if ((typedValue.mType->IsValuelessNonOpaqueType()) || (typedValue.mType->IsVar())) if ((typedValue.mType->IsValuelessType()) || (typedValue.mType->IsVar()))
return BfTypedValue(mBfIRBuilder->GetFakeVal(), typedValue.mType, false); return BfTypedValue(mBfIRBuilder->GetFakeVal(), typedValue.mType, false);
if (typedValue.mValue.IsConst()) if (typedValue.mValue.IsConst())