From 04fe692bba78cc8704262517c4ec7aa19bca6014 Mon Sep 17 00:00:00 2001 From: nikozer Date: Tue, 15 Jul 2025 17:26:44 +0300 Subject: [PATCH] fix codecheck 0702 Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICMKAG Tests: ninja tests Signed-off-by: nikozer --- .../compiler/lowering/ets/objectIndexAccess.cpp | 2 +- .../compiler/lowering/ets/objectIterator.cpp | 3 ++- .../lowering/ets/objectLiteralLowering.cpp | 2 +- .../compiler/lowering/ets/restArgsLowering.cpp | 6 +++++- .../compiler/lowering/ets/restTupleLowering.cpp | 5 ++++- .../compiler/lowering/ets/spreadLowering.cpp | 2 ++ .../compiler/lowering/ets/stringComparison.cpp | 1 + .../ets/topLevelStmts/globalClassHandler.cpp | 15 +++++++++++++-- .../ets/topLevelStmts/globalDeclTransformer.cpp | 9 ++++++++- ets2panda/compiler/lowering/ets/unionLowering.cpp | 15 ++++++++++----- ets2panda/ir/statements/tryStatement.cpp | 8 +++++++- ets2panda/parser/TSparser.cpp | 2 +- ets2panda/parser/TypedParser.cpp | 3 ++- 13 files changed, 57 insertions(+), 16 deletions(-) diff --git a/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp b/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp index 2e0b7f8328..c57d29aa9c 100644 --- a/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp +++ b/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp @@ -71,7 +71,7 @@ ir::Expression *ObjectIndexLowering::ProcessIndexSetAccess(parser::ETSParser *pa memberExpression->Property(), assignmentExpression->Right()); setter = loweringResult; } - ES2PANDA_ASSERT(loweringResult != nullptr); + ES2PANDA_ASSERT(loweringResult != nullptr && setter != nullptr); loweringResult->SetParent(assignmentExpression->Parent()); loweringResult->SetRange(assignmentExpression->Range()); setter->AddModifier(ir::ModifierFlags::ARRAY_SETTER); diff --git a/ets2panda/compiler/lowering/ets/objectIterator.cpp b/ets2panda/compiler/lowering/ets/objectIterator.cpp index fa649a253b..94293d0079 100644 --- a/ets2panda/compiler/lowering/ets/objectIterator.cpp +++ b/ets2panda/compiler/lowering/ets/objectIterator.cpp @@ -159,6 +159,7 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(public_lib::Context loopVariableIdent = declaration->Declarators().at(0U)->Id()->AsIdentifier()->Clone(allocator, nullptr); } else if (left->IsIdentifier()) { loopVariableIdent = Gensym(allocator); + ES2PANDA_ASSERT(loopVariableIdent != nullptr); loopVariableIdent->SetName(left->AsIdentifier()->Name()); } else { ES2PANDA_UNREACHABLE(); @@ -167,7 +168,7 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(public_lib::Context // Parse ArkTS code string and create corresponding AST nodes auto *const parser = ctx->parser->AsETSParser(); - ES2PANDA_ASSERT(parser != nullptr); + ES2PANDA_ASSERT(parser != nullptr && nextIdent != nullptr && iterIdent != nullptr); auto *const loweringResult = parser->CreateFormattedStatement( whileStatement, iterIdent, forOfStatement->Right(), nextIdent, iterIdent->Clone(allocator, nullptr), diff --git a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp index b593f51c3e..0a17664868 100644 --- a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp @@ -192,6 +192,7 @@ static void GenerateNewStatements(public_lib::Context *ctx, ir::ObjectExpression // Generating: let : = new (); auto *genSymIdent = Gensym(allocator); auto *type = ctx->AllocNode(classType, allocator); + ES2PANDA_ASSERT(genSymIdent != nullptr && type != nullptr); ss << "let @@I" << addNode(genSymIdent) << ": @@T" << addNode(type) << " = new @@T" << addNode(type->Clone(allocator, nullptr)) << "();" << std::endl; @@ -225,7 +226,6 @@ static void GenerateNewStatements(public_lib::Context *ctx, ir::ObjectExpression if (isAnonymous && CheckReadonlyAndUpdateCtorArgs(keyIdent, value, ctorArgumentsMap)) { continue; } - ES2PANDA_ASSERT(genSymIdent != nullptr); ss << "@@I" << addNode(genSymIdent->Clone(allocator, nullptr)) << ".@@I" << addNode(keyIdent); if (value->IsBlockExpression()) { diff --git a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp index 952da6e17e..8378bdad0b 100644 --- a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp @@ -34,9 +34,13 @@ static ir::BlockExpression *CreateRestArgsBlockExpression(public_lib::Context *c ArenaVector blockStatements(allocator->Adapter()); const auto arraySymbol = Gensym(allocator); + ES2PANDA_ASSERT(arraySymbol != nullptr); const auto argumentSymbol = Gensym(allocator); + ES2PANDA_ASSERT(argumentSymbol != nullptr); const auto iteratorIndex = Gensym(allocator); + ES2PANDA_ASSERT(iteratorIndex != nullptr); const auto iteratorSymbol = Gensym(allocator); + ES2PANDA_ASSERT(iteratorSymbol != nullptr); const auto elementType = checker->GetElementTypeOfArray(spreadElement->Argument()->TsType()); auto *typeNode = allocator->New(elementType, allocator); blockStatements.push_back( @@ -51,7 +55,6 @@ static ir::BlockExpression *CreateRestArgsBlockExpression(public_lib::Context *c args.emplace_back(argumentSymbol->Clone(allocator, nullptr)); ss << "@@I3[@@I4] = @@I5;"; args.emplace_back(arraySymbol->Clone(allocator, nullptr)); - ES2PANDA_ASSERT(iteratorIndex != nullptr); args.emplace_back(iteratorIndex->Clone(allocator, nullptr)); args.emplace_back(iteratorSymbol->Clone(allocator, nullptr)); ss << "@@I6 = @@I7 + 1;"; @@ -116,6 +119,7 @@ static ir::Expression *CreateRestArgsArray(public_lib::Context *context, ArenaVe // ss << "Array.from<@@T4>(@@I5);"; // Now: // NOTE: refactor me! + ES2PANDA_ASSERT(genSymIdent != nullptr && genSymIdent2 != nullptr); ss << "let @@I1 : FixedArray<@@T2> = @@E3;"; ss << "let @@I4 : Array<@@T5> = new Array<@@T6>(@@I7.length);"; ss << "for (let i = 0; i < @@I8.length; ++i) { @@I9[i] = @@I10[i]}"; diff --git a/ets2panda/compiler/lowering/ets/restTupleLowering.cpp b/ets2panda/compiler/lowering/ets/restTupleLowering.cpp index 14aff4b616..d584a899fa 100644 --- a/ets2panda/compiler/lowering/ets/restTupleLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restTupleLowering.cpp @@ -213,6 +213,7 @@ ir::ArrayExpression *CreateArrayExpression(public_lib::Context *ctx, const Arena for (auto tupleElementAnno : newRestParams) { auto &tupleElementName = tupleElementAnno->AsETSParameterExpression()->Ident()->AsIdentifier()->Name(); ir::Expression *arg = ctx->AllocNode(tupleElementName, allocator); + ES2PANDA_ASSERT(arg != nullptr); arg->SetParent(arrayExpr); elements.push_back(arg); } @@ -268,7 +269,9 @@ ir::ScriptFunction *CreateNewScriptFunction(public_lib::Context *ctx, ir::Script ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : scriptFunc->Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, newScriptFunc)->AsAnnotationUsage()); + auto *newAnnotationUsage = annotationUsage->Clone(allocator, newScriptFunc); + ES2PANDA_ASSERT(newAnnotationUsage != nullptr); + annotationUsages.push_back(newAnnotationUsage->AsAnnotationUsage()); } newScriptFunc->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index 416e61cd70..fe71baaaf6 100644 --- a/ets2panda/compiler/lowering/ets/spreadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/spreadLowering.cpp @@ -87,6 +87,7 @@ static ir::Identifier *CreateNewArrayDeclareStatement(public_lib::Context *ctx, auto *const allocator = ctx->allocator; auto *const parser = ctx->parser->AsETSParser(); ir::Identifier *newArrayId = Gensym(allocator); + ES2PANDA_ASSERT(newArrayId != nullptr); checker::Type *arrayElementType = checker->GetElementTypeOfArray(array->TsType()); // NOTE: If arrayElementType is ETSUnionType(String|Int) or ETSObjectType(private constructor) or ..., we cannot @@ -335,6 +336,7 @@ static ir::BlockExpression *CreateLoweredExpressionForArray(public_lib::Context ir::Identifier *newArrayId = CreateNewArrayDeclareStatement(ctx, array, statements, newArrayLengthId); ES2PANDA_ASSERT(newArrayId != nullptr); ir::Identifier *newArrayIndexId = Gensym(allocator); + ES2PANDA_ASSERT(newArrayIndexId != nullptr); statements.emplace_back( parser->CreateFormattedStatement("let @@I1 = 0", newArrayIndexId->Clone(allocator, nullptr))); std::vector newArrayAndIndex {newArrayId->Clone(allocator, nullptr), diff --git a/ets2panda/compiler/lowering/ets/stringComparison.cpp b/ets2panda/compiler/lowering/ets/stringComparison.cpp index e25361a710..68d18c745e 100644 --- a/ets2panda/compiler/lowering/ets/stringComparison.cpp +++ b/ets2panda/compiler/lowering/ets/stringComparison.cpp @@ -84,6 +84,7 @@ void StringComparisonLowering::ProcessBinaryExpression(ir::BinaryExpression *exp auto *zeroExpr = checker->AllocNode(lexer::Number(int32_t(0))); auto *const callee = checker->AllocNode("compareTo", checker->Allocator()); ES2PANDA_ASSERT(callee != nullptr); + ES2PANDA_ASSERT(checker->GlobalBuiltinETSStringType() != nullptr); auto *var = checker->GlobalBuiltinETSStringType()->GetProperty(callee->AsIdentifier()->Name(), checker::PropertySearchFlags::SEARCH_METHOD); callee->SetVariable(var); diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp index 63ee341389..857b07c9a0 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp @@ -159,6 +159,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateTransformedClass(ir::ETSModule * { auto className = ns->Ident()->Name(); auto *ident = NodeAllocator::Alloc(allocator_, className, allocator_); + ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(ns->Ident()->Range()); auto *classDef = NodeAllocator::Alloc(allocator_, allocator_, ident, @@ -168,6 +169,8 @@ ir::ClassDeclaration *GlobalClassHandler::CreateTransformedClass(ir::ETSModule * classDef->SetRange(ns->Range()); classDef->AddModifier(ns->Modifiers()); auto *classDecl = NodeAllocator::Alloc(allocator_, classDef, allocator_); + ES2PANDA_ASSERT(classDecl != nullptr); + classDecl->SetRange(ns->Range()); classDecl->AddModifier(ns->Modifiers()); classDef->SetNamespaceTransformed(); ArenaVector annotations {allocator_->Adapter()}; @@ -427,6 +430,7 @@ ir::MethodDefinition *GlobalClassHandler::CreateGlobalMethod(const std::string_v const auto functionFlags = ir::ScriptFunctionFlags::NONE; auto functionModifiers = ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC; auto ident = NodeAllocator::Alloc(allocator_, name, allocator_); + ES2PANDA_ASSERT(ident != nullptr); auto body = NodeAllocator::ForceSetParent(allocator_, allocator_, std::move(statements)); auto funcSignature = ir::FunctionSignature(nullptr, ArenaVector(allocator_->Adapter()), nullptr); @@ -439,9 +443,12 @@ ir::MethodDefinition *GlobalClassHandler::CreateGlobalMethod(const std::string_v func->AddModifier(functionModifiers); auto *funcExpr = NodeAllocator::Alloc(allocator_, func); + auto *identClone = ident->Clone(allocator_, nullptr); + ES2PANDA_ASSERT(identClone != nullptr); auto *methodDef = NodeAllocator::Alloc(allocator_, ir::MethodDefinitionKind::METHOD, - ident->Clone(allocator_, nullptr)->AsExpression(), - funcExpr, functionModifiers, allocator_, false); + identClone->AsExpression(), funcExpr, + functionModifiers, allocator_, false); + ES2PANDA_ASSERT(methodDef != nullptr); auto minBound = lexer::SourcePosition(globalProgram_); auto maxBound = lexer::SourcePosition(globalProgram_); if (!body->Statements().empty()) { @@ -498,6 +505,7 @@ void GlobalClassHandler::AddInitCallToStaticBlock(ir::ClassDefinition *globalCla auto *blockBody = staticBlock->Function()->Body()->AsBlockStatement(); auto exprStmt = NodeAllocator::Alloc(allocator_, callExpr); + ES2PANDA_ASSERT(exprStmt != nullptr); exprStmt->SetParent(blockBody); blockBody->AddStatement(exprStmt); } @@ -598,6 +606,7 @@ ir::ClassStaticBlock *GlobalClassHandler::CreateStaticBlock(ir::ClassDefinition auto *funcExpr = NodeAllocator::Alloc(allocator_, func); auto *staticBlock = NodeAllocator::Alloc(allocator_, funcExpr, allocator_); + ES2PANDA_ASSERT(staticBlock != nullptr); staticBlock->AddModifier(ir::ModifierFlags::STATIC); staticBlock->SetRange({classDef->Start(), classDef->Start()}); return staticBlock; @@ -648,6 +657,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateGlobalClass(const parser::Progra const auto rangeToStartOfFile = lexer::SourceRange(lexer::SourcePosition(globalProgram), lexer::SourcePosition(globalProgram)); auto *ident = NodeAllocator::Alloc(allocator_, compiler::Signatures::ETS_GLOBAL, allocator_); + ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(rangeToStartOfFile); auto *classDef = NodeAllocator::Alloc(allocator_, allocator_, ident, ir::ClassDefinitionModifiers::GLOBAL, @@ -655,6 +665,7 @@ ir::ClassDeclaration *GlobalClassHandler::CreateGlobalClass(const parser::Progra ES2PANDA_ASSERT(classDef != nullptr); classDef->SetRange(rangeToStartOfFile); auto *classDecl = NodeAllocator::Alloc(allocator_, classDef, allocator_); + ES2PANDA_ASSERT(classDecl != nullptr); classDecl->SetRange(rangeToStartOfFile); return classDecl; diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp index a5abdb80a0..2ec4129350 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp @@ -75,6 +75,7 @@ void GlobalDeclTransformer::VisitFunctionDeclaration(ir::FunctionDeclaration *fu auto *method = util::NodeAllocator::ForceSetParent( allocator_, methodKind, funcDecl->Function()->Id()->Clone(allocator_, nullptr), funcExpr, funcDecl->Function()->Modifiers(), allocator_, false); + ES2PANDA_ASSERT(method != nullptr && method->Function() != nullptr); method->SetRange(funcDecl->Range()); method->Function()->SetAnnotations(funcDecl->Annotations()); @@ -97,6 +98,7 @@ void GlobalDeclTransformer::VisitVariableDeclaration(ir::VariableDeclaration *va currentModule_->AsETSModule()->Program()->IsPackage(); auto *field = util::NodeAllocator::ForceSetParent( allocator_, id->Clone(allocator_, nullptr), declarator->Init(), typeAnn, modifiers, allocator_, false); + ES2PANDA_ASSERT(field != nullptr); field->SetInitInStaticBlock(needInitializeInStaticBlock); field->SetRange(declarator->Range()); @@ -104,7 +106,9 @@ void GlobalDeclTransformer::VisitVariableDeclaration(ir::VariableDeclaration *va ArenaVector propAnnotations(allocator_->Adapter()); for (auto *annotationUsage : varDecl->Annotations()) { ES2PANDA_ASSERT(annotationUsage != nullptr); - propAnnotations.push_back(annotationUsage->Clone(allocator_, field)->AsAnnotationUsage()); + auto annotationUsageClone = annotationUsage->Clone(allocator_, field); + ES2PANDA_ASSERT(annotationUsageClone != nullptr); + propAnnotations.push_back(annotationUsageClone->AsAnnotationUsage()); } field->SetAnnotations(std::move(propAnnotations)); } @@ -172,12 +176,14 @@ ir::Identifier *GlobalDeclTransformer::RefIdent(const util::StringView &name) ir::ExpressionStatement *GlobalDeclTransformer::InitTopLevelProperty(ir::ClassProperty *classProperty) { const auto initializer = classProperty->Value(); + ES2PANDA_ASSERT(classProperty->Id() != nullptr); if (classProperty->IsConst() || initializer == nullptr) { classProperty->SetStart(classProperty->Id()->Start()); return nullptr; } auto const ident = RefIdent(classProperty->Id()->Name()); + ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(classProperty->Id()->Range()); initializer->SetParent(nullptr); @@ -188,6 +194,7 @@ ir::ExpressionStatement *GlobalDeclTransformer::InitTopLevelProperty(ir::ClassPr assignmentExpression->SetTsType(initializer->TsType()); auto expressionStatement = util::NodeAllocator::Alloc(allocator_, assignmentExpression); + ES2PANDA_ASSERT(expressionStatement != nullptr); expressionStatement->SetRange(classProperty->Range()); classProperty->SetRange({ident->Start(), initializer->End()}); diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index aba0545179..1710ce3ed4 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -57,6 +57,7 @@ static ir::ClassDefinition *GetUnionAccessClass(public_lib::Context *ctx, varbin util::UString unionFieldClassName(util::StringView(name), allocator); auto *ident = ctx->AllocNode(unionFieldClassName.View(), allocator); auto [decl, var] = varbinder->NewVarDecl(ident->Start(), ident->Name()); + ES2PANDA_ASSERT(ident != nullptr); ident->SetVariable(var); auto classCtx = varbinder::LexicalScope(varbinder); @@ -65,6 +66,7 @@ static ir::ClassDefinition *GetUnionAccessClass(public_lib::Context *ctx, varbin ES2PANDA_ASSERT(classDef != nullptr); classDef->SetScope(classCtx.GetScope()); auto *classDecl = ctx->AllocNode(classDef, allocator); + ES2PANDA_ASSERT(classDecl != nullptr); classDef->Scope()->BindNode(classDecl->Definition()); decl->BindNode(classDef); var->SetScope(classDef->Scope()); @@ -84,8 +86,9 @@ static std::tuple CreateNamedA { auto *allocator = ctx->Allocator(); auto *checker = ctx->GetChecker()->AsETSChecker(); - - auto unionType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType()))->AsETSUnionType(); + auto apparentType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType())); + ES2PANDA_ASSERT(apparentType != nullptr); + auto unionType = apparentType->AsETSUnionType(); auto *const accessClass = GetUnionAccessClass(ctx, varbinder, GetAccessClassName(unionType)); auto methodName = expr->TsType()->AsETSFunctionType()->Name(); @@ -104,7 +107,7 @@ static std::tuple CreateNamedA nullptr, ir::FunctionSignature(nullptr, std::move(params), returnTypeAnno), // CC-OFFNXT(G.FMT.02-CPP) project code style ir::ScriptFunctionFlags::METHOD, ir::ModifierFlags::PUBLIC}); - ES2PANDA_ASSERT(func != nullptr); + ES2PANDA_ASSERT(func != nullptr && methodIdent != nullptr); func->SetIdent(methodIdent->Clone(allocator, nullptr)); // Create the synthetic function node @@ -124,7 +127,7 @@ static std::tuple CreateNamedA auto boundCtx = varbinder::BoundContext(varbinder->AsETSBinder()->GetRecordTable(), accessClass, true); CheckLoweredNode(varbinder->AsETSBinder(), checker, method); } - + ES2PANDA_ASSERT(method->Id() != nullptr && method->TsType() != nullptr); return {method->Id()->Variable()->AsLocalVariable(), method->TsType()->AsETSFunctionType()->CallSignatures().front()}; } @@ -135,7 +138,9 @@ static varbinder::LocalVariable *CreateNamedAccessProperty(public_lib::Context * auto *const allocator = ctx->Allocator(); auto *checker = ctx->GetChecker()->AsETSChecker(); - auto unionType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType()))->AsETSUnionType(); + auto apparentType = checker->GetApparentType(checker->GetNonNullishType(expr->Object()->TsType())); + ES2PANDA_ASSERT(apparentType != nullptr); + auto unionType = apparentType->AsETSUnionType(); auto *const accessClass = GetUnionAccessClass(ctx, varbinder, GetAccessClassName(unionType)); auto propName = expr->Property()->AsIdentifier()->Name(); auto fieldType = expr->TsType(); diff --git a/ets2panda/ir/statements/tryStatement.cpp b/ets2panda/ir/statements/tryStatement.cpp index 82d74865c4..acc5b4d085 100644 --- a/ets2panda/ir/statements/tryStatement.cpp +++ b/ets2panda/ir/statements/tryStatement.cpp @@ -125,7 +125,13 @@ TryStatement::TryStatement(TryStatement const &other, ArenaAllocator *allocator) finalizerInsertions_(allocator->Adapter()), finallyCanCompleteNormally_(other.finallyCanCompleteNormally_) { - block_ = other.block_ == nullptr ? nullptr : other.block_->Clone(allocator, this)->AsBlockStatement(); + if (other.block_ == nullptr) { + block_ = nullptr; + } else { + auto *blockClone = other.block_->Clone(allocator, this); + ES2PANDA_ASSERT(blockClone != nullptr); + block_ = blockClone->AsBlockStatement(); + } for (auto &cc : other.catchClauses_) { if (cc == nullptr) { catchClauses_.push_back(nullptr); diff --git a/ets2panda/parser/TSparser.cpp b/ets2panda/parser/TSparser.cpp index 4c41a234a3..69368d4acc 100644 --- a/ets2panda/parser/TSparser.cpp +++ b/ets2panda/parser/TSparser.cpp @@ -754,7 +754,7 @@ ir::TSTypeParameter *TSParser::ParseMappedTypeParameter() lexer::SourcePosition endLoc = constraint->End(); auto *typeParameter = AllocNode(paramName, constraint, nullptr, Allocator()); - + ES2PANDA_ASSERT(typeParameter != nullptr); typeParameter->SetRange({startLoc, endLoc}); return typeParameter; diff --git a/ets2panda/parser/TypedParser.cpp b/ets2panda/parser/TypedParser.cpp index 581e8dde26..474bfaa6ef 100644 --- a/ets2panda/parser/TypedParser.cpp +++ b/ets2panda/parser/TypedParser.cpp @@ -296,7 +296,7 @@ ir::TSModuleDeclaration *TypedParser::ParseAmbientExternalModuleDeclaration(cons name = AllocNode(Lexer()->GetToken().String()); } - + ES2PANDA_ASSERT(name != nullptr); name->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); @@ -511,6 +511,7 @@ ir::Statement *TypedParser::ParseInterfaceDeclaration(bool isStatic) auto members = ParseTypeLiteralOrInterface(); auto *body = AllocNode(std::move(members)); + ES2PANDA_ASSERT(body != nullptr); body->SetRange({bodyStart, Lexer()->GetToken().End()}); const auto isExternal = IsExternal(); -- Gitee