From eab378c016d573c53245ec056c8ae8f88a20bf0e Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 30 Apr 2020 10:25:06 -0700 Subject: [PATCH] Fixed a const int casting issue --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 1f30b74e..ae15d222 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -6648,14 +6648,6 @@ BfTypedValue BfModule::TryLookupGenericConstVaue(BfIdentifierNode* identifierNod if ((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) != 0) { - if ((genericTypeConstraint != NULL) && (expectingType != NULL)) - { - if (!CanCast(BfTypedValue(mBfIRBuilder->GetFakeVal(), genericTypeConstraint), expectingType)) - { - Fail(StrFormat("Generic constraint '%s' is not convertible to 'int'", TypeToString(genericTypeConstraint).c_str()), identifierNode); - } - } - BfTypedValue result; result.mType = genericParamResult; result.mKind = BfTypedValueKind_GenericConstValue; @@ -8828,7 +8820,9 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp auto undefConst = (BfConstantUndef*)constant; auto fakeVal = GetFakeTypedValue(GetPrimitiveType(undefConst->mTypeCode)); - auto val = CastToValue(srcNode, fakeVal, toType, (BfCastFlags)(castFlags | BfCastFlags_Explicit)); + // Why did we have this BfCastFlags_Explicit? It broke creating errors on things like "int16 val = TCount;" + //auto val = CastToValue(srcNode, fakeVal, toType, (BfCastFlags)(castFlags | BfCastFlags_Explicit)); + auto val = CastToValue(srcNode, fakeVal, toType, castFlags); if (val) return val; }