mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed tuple duplicate name check circular dependency issue
This commit is contained in:
parent
1a44732189
commit
d46c60d956
3 changed files with 22 additions and 5 deletions
|
@ -17203,6 +17203,7 @@ void BfExprEvaluator::Visit(BfTupleExpression* tupleExpr)
|
|||
{
|
||||
BfTypeVector fieldTypes;
|
||||
Array<String> fieldNames;
|
||||
HashSet<String> fieldNameSet;
|
||||
for (auto typedVal : typedValues)
|
||||
{
|
||||
auto type = typedVal.mType;
|
||||
|
@ -17216,7 +17217,14 @@ void BfExprEvaluator::Visit(BfTupleExpression* tupleExpr)
|
|||
if (requestedName == NULL)
|
||||
fieldNames.push_back("");
|
||||
else
|
||||
fieldNames.push_back(requestedName->mNameNode->ToString());
|
||||
{
|
||||
auto fieldName = requestedName->mNameNode->ToString();
|
||||
if (!fieldNameSet.TryAdd(fieldName, NULL))
|
||||
{
|
||||
mModule->Fail(StrFormat("A field named '%s' has already been declared", fieldName.c_str()), requestedName->mNameNode);
|
||||
}
|
||||
fieldNames.push_back(fieldName);
|
||||
}
|
||||
}
|
||||
tupleType = mModule->CreateTupleType(fieldTypes, fieldNames);
|
||||
}
|
||||
|
|
|
@ -2361,8 +2361,10 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
SetAndRestoreValue<BfTypeReference*> prevTypeRef(mContext->mCurTypeState->mCurBaseTypeRef, checkTypeRef);
|
||||
SetAndRestoreValue<BfTypeDefineState> prevDefineState(typeInstance->mDefineState, BfTypeDefineState_ResolvingBaseType);
|
||||
|
||||
bool populateBase = !typeInstance->mTypeFailed;
|
||||
auto checkType = ResolveTypeRef(checkTypeRef, populateBase ? BfPopulateType_Data : BfPopulateType_Declaration);
|
||||
bool populateBase = !typeInstance->mTypeFailed;
|
||||
auto checkType = ResolveTypeRef(checkTypeRef, BfPopulateType_Declaration);
|
||||
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
||||
PopulateType(checkType, BfPopulateType_Data);
|
||||
|
||||
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
||||
{
|
||||
|
@ -7206,8 +7208,9 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
|
||||
if (typeInstance->IsTuple())
|
||||
{
|
||||
if (typeInstance->mDefineState < BfTypeDefineState_Defined)
|
||||
PopulateType(typeInstance);
|
||||
//TODO: This can cause circular reference issues. Is there a case this is needed?
|
||||
//if (typeInstance->mDefineState < BfTypeDefineState_Defined)
|
||||
// PopulateType(typeInstance);
|
||||
if (typeInstance->mHasDeclError)
|
||||
{
|
||||
if (auto tupleTypeRef = BfNodeDynCast<BfTupleTypeRef>(typeRef))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
|
@ -118,6 +119,11 @@ namespace Tests
|
|||
int32 mB;
|
||||
}
|
||||
|
||||
struct StructK
|
||||
{
|
||||
Dictionary<int, StructK> dict;
|
||||
}
|
||||
|
||||
[Test]
|
||||
static void TestBasics()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue