mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Restrict const expression usage to generic arguments
This commit is contained in:
parent
2b9443744b
commit
071dfa8e09
4 changed files with 19 additions and 3 deletions
|
@ -1086,7 +1086,8 @@ void BeIRCodeGen::Read(BeMDNode*& llvmMD)
|
||||||
llvmMD = result.mBeMetadata;
|
llvmMD = result.mBeMetadata;
|
||||||
BE_MEM_END("BeMDNode");
|
BE_MEM_END("BeMDNode");
|
||||||
|
|
||||||
llvmMD->mRefCount++;
|
if (llvmMD != NULL)
|
||||||
|
llvmMD->mRefCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeIRCodeGen::HandleNextCmd()
|
void BeIRCodeGen::HandleNextCmd()
|
||||||
|
|
|
@ -10795,7 +10795,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
lookupCtx.mResolveFlags = (BfResolveTypeRefFlags)(resolveFlags &
|
lookupCtx.mResolveFlags = (BfResolveTypeRefFlags)(resolveFlags &
|
||||||
(BfResolveTypeRefFlag_NoCreate | BfResolveTypeRefFlag_IgnoreLookupError | BfResolveTypeRefFlag_DisallowComptime |
|
(BfResolveTypeRefFlag_NoCreate | BfResolveTypeRefFlag_IgnoreLookupError | BfResolveTypeRefFlag_DisallowComptime |
|
||||||
BfResolveTypeRefFlag_AllowInferredSizedArray | BfResolveTypeRefFlag_Attribute | BfResolveTypeRefFlag_AllowUnboundGeneric |
|
BfResolveTypeRefFlag_AllowInferredSizedArray | BfResolveTypeRefFlag_Attribute | BfResolveTypeRefFlag_AllowUnboundGeneric |
|
||||||
BfResolveTypeRefFlag_ForceUnboundGeneric));
|
BfResolveTypeRefFlag_ForceUnboundGeneric | BfResolveTypeRefFlag_AllowGenericParamConstValue));
|
||||||
lookupCtx.mRootTypeRef = typeRef;
|
lookupCtx.mRootTypeRef = typeRef;
|
||||||
lookupCtx.mRootTypeDef = typeDef;
|
lookupCtx.mRootTypeDef = typeDef;
|
||||||
lookupCtx.mModule = this;
|
lookupCtx.mModule = this;
|
||||||
|
|
|
@ -3868,6 +3868,13 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
|
||||||
}
|
}
|
||||||
else if (auto constExprTypeRef = BfNodeDynCastExact<BfConstExprTypeRef>(typeRef))
|
else if (auto constExprTypeRef = BfNodeDynCastExact<BfConstExprTypeRef>(typeRef))
|
||||||
{
|
{
|
||||||
|
if ((flags & BfHashFlag_AllowGenericParamConstValue) == 0)
|
||||||
|
{
|
||||||
|
ctx->mModule->Fail("Invalid use of const expression", constExprTypeRef->mConstToken);
|
||||||
|
ctx->mFailed = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BfVariant result;
|
BfVariant result;
|
||||||
BfType* resultType = NULL;
|
BfType* resultType = NULL;
|
||||||
if (constExprTypeRef->mConstExpr != NULL)
|
if (constExprTypeRef->mConstExpr != NULL)
|
||||||
|
|
|
@ -2658,7 +2658,15 @@ public:
|
||||||
|
|
||||||
int tryCount = 0;
|
int tryCount = 0;
|
||||||
ctx->mFailed = false;
|
ctx->mFailed = false;
|
||||||
int hashVal = Hash(findType, ctx, BfHashFlag_AllowRef);
|
|
||||||
|
BfHashFlags hashFlags = BfHashFlag_AllowRef;
|
||||||
|
if ((ctx->mResolveFlags & BfResolveTypeRefFlag_AllowGenericParamConstValue) != 0)
|
||||||
|
{
|
||||||
|
ctx->mResolveFlags = (BfResolveTypeRefFlags)(ctx->mResolveFlags & ~BfResolveTypeRefFlag_AllowGenericParamConstValue);
|
||||||
|
hashFlags = (BfHashFlags)(hashFlags | BfHashFlag_AllowGenericParamConstValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hashVal = Hash(findType, ctx, hashFlags);
|
||||||
if ((ctx->mFailed) || (ctx->mHadVar))
|
if ((ctx->mFailed) || (ctx->mHadVar))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue