diff --git a/BeefLibs/corlib/src/Attribute.bf b/BeefLibs/corlib/src/Attribute.bf index af9f24aa..9f33dd5f 100644 --- a/BeefLibs/corlib/src/Attribute.bf +++ b/BeefLibs/corlib/src/Attribute.bf @@ -505,11 +505,21 @@ namespace System [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Interface | .Property)] public struct ObsoleteAttribute : Attribute { + public this() + { + + } + public this(bool isError) { } + public this(String error) + { + + } + public this(String error, bool isError) { diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 1d1f87d6..cab53a14 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -3414,7 +3414,7 @@ void BfModule::CheckErrorAttributes(BfTypeInstance* typeInstance, BfMethodInstan BfIRConstHolder* constHolder = typeInstance->mConstHolder; auto customAttribute = customAttributes->Get(mCompiler->mObsoleteAttributeTypeDef); - if ((customAttribute != NULL) && (!customAttribute->mCtorArgs.IsEmpty()) && (targetSrc != NULL)) + if ((customAttribute != NULL) && (targetSrc != NULL)) { String err; if (fieldInstance != NULL) @@ -3426,23 +3426,29 @@ void BfModule::CheckErrorAttributes(BfTypeInstance* typeInstance, BfMethodInstan bool isError = false; - auto constant = constHolder->GetConstant(customAttribute->mCtorArgs[0]); - if (constant->mTypeCode == BfTypeCode_Boolean) + if (customAttribute->mCtorArgs.size() >= 1) { - isError = constant->mBool; - } - else if (customAttribute->mCtorArgs.size() >= 2) - { - String* str = GetStringPoolString(customAttribute->mCtorArgs[0], constHolder); - if (str != NULL) + auto constant = constHolder->GetConstant(customAttribute->mCtorArgs[0]); + if (constant->mTypeCode == BfTypeCode_Boolean) { - err += ":\n '"; - err += *str; - err += "'"; + isError = constant->mBool; } + else if (constant->mTypeCode == BfTypeCode_StringId) + { + String* str = GetStringPoolString(customAttribute->mCtorArgs[0], constHolder); + if (str != NULL) + { + err += ":\n '"; + err += *str; + err += "'"; + } - constant = constHolder->GetConstant(customAttribute->mCtorArgs[1]); - isError = constant->mBool; + if (customAttribute->mCtorArgs.size() >= 2) + { + constant = constHolder->GetConstant(customAttribute->mCtorArgs[1]); + isError = constant->mBool; + } + } } BfError* error = NULL; @@ -26196,4 +26202,4 @@ void BfModule::ClearModule() } if (mNextAltModule != NULL) mNextAltModule->ClearModule(); -} \ No newline at end of file +}