From b512559716f93bd36a9cbab1aa38b295b77f3fa2 Mon Sep 17 00:00:00 2001 From: Robert Sipka Date: Mon, 21 Nov 2022 16:04:18 +0100 Subject: [PATCH] Minor fix in location handling Expanding a type error message to be more detailed Signed-off-by: Robert Sipka --- checker/ets/object.cpp | 3 ++- lexer/token/sourceLocation.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/checker/ets/object.cpp b/checker/ets/object.cpp index 6af955bb2..19f29f7db 100644 --- a/checker/ets/object.cpp +++ b/checker/ets/object.cpp @@ -75,7 +75,8 @@ ETSObjectType *ETSChecker::GetSuperType(ETSObjectType *type) Type *superType = classDef->Super()->AsTypeNode()->GetType(this); if (!superType->IsETSObjectType() || !superType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::CLASS)) { - ThrowTypeError("Super type is not extensible.", classDef->Super()->Start()); + ThrowTypeError({"The super type of '", classDef->Ident()->Name(), "' class is not extensible."}, + classDef->Super()->Start()); } ETSObjectType *superObj = superType->AsETSObjectType(); diff --git a/lexer/token/sourceLocation.cpp b/lexer/token/sourceLocation.cpp index c44691600..6d03ee19e 100644 --- a/lexer/token/sourceLocation.cpp +++ b/lexer/token/sourceLocation.cpp @@ -75,6 +75,11 @@ SourceLocation LineIndex::GetLocation(SourcePosition pos) noexcept size_t col = 0; + // It can occur during stdlib parsing where entries does not uploaded + if (line > entrys_.size()) { + return SourceLocation(line + 1, col + 1); + } + if (line == entrys_.size()) { --line; } -- Gitee