Log error when variable is unknown type.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0fbca3f01e
commit
ce3d92e0a5
|
@ -1,10 +1,11 @@
|
|||
#include "Binder.hpp"
|
||||
#include "../CoreData/PrimitiveTypes.hpp"
|
||||
#include "../Diagnostics/Logger.hpp"
|
||||
using namespace MalachScript::Parser;
|
||||
using namespace MalachScript::Diagnostics;
|
||||
|
||||
namespace MalachScript::Binder {
|
||||
static const BoundType* UnknownType = new BoundType("???"_id, ClassAttr::None, 0);
|
||||
|
||||
void Binder::Bind(BoundNamespace* ns, const std::vector<const MalachScript::Parser::ParsedStatement*>& statements,
|
||||
const Binder::log_func& log) {
|
||||
for (const auto* s : statements) {
|
||||
|
@ -195,7 +196,9 @@ namespace MalachScript::Binder {
|
|||
// FIXME: Resolve namespace of scoped identifier
|
||||
auto type = ResolveType(ns, typeStatement->GetScopedIdentifier().GetIdentifier());
|
||||
if (!type.has_value()) {
|
||||
throw std::logic_error("Shouldn't be reached");
|
||||
log(DiagnosticLevel::Error, DiagnosticType::UnknownType, typeStatement->GetSpan(),
|
||||
{typeStatement->GetScopedIdentifier().GetIdentifier().GetStdString()});
|
||||
type = UnknownType;
|
||||
}
|
||||
if (activeType.has_value()) {
|
||||
activeType.value()->AddField(var->GetIdentifier(),
|
||||
|
|
|
@ -312,27 +312,31 @@ namespace MalachScript::Parser {
|
|||
}
|
||||
ScopedIdentifier scopedIdentifier;
|
||||
ParseScope(scopedIdentifier.GetScope(), current, log);
|
||||
auto end = current->GetSpan().GetEnd();
|
||||
if (!ParseDataType(scopedIdentifier.GetIdentifier(), current, log)) {
|
||||
return false;
|
||||
}
|
||||
// TODO: Generics.
|
||||
if (current->GetKind() == LexTokenKind::OpenBlockParenthesisSymbol) {
|
||||
end = current->GetSpan().GetEnd();
|
||||
PROGRESS_TOKEN(current);
|
||||
if (current->GetKind() != LexTokenKind::CloseBlockParenthesisSymbol) {
|
||||
logUnexpectedToken(CloseCurlyParenthesisSymbol, current);
|
||||
} else {
|
||||
end = current->GetSpan().GetEnd();
|
||||
PROGRESS_TOKEN(current);
|
||||
isArray = true;
|
||||
}
|
||||
} else if (current->GetKind() == LexTokenKind::AtSymbol) {
|
||||
isHandle = true;
|
||||
end = current->GetSpan().GetEnd();
|
||||
PROGRESS_TOKEN(current);
|
||||
if (current->GetKind() == LexTokenKind::ConstKeyword) {
|
||||
isConst = true;
|
||||
end = current->GetSpan().GetEnd();
|
||||
PROGRESS_TOKEN(current);
|
||||
}
|
||||
}
|
||||
auto end = current->GetSpan().GetEnd();
|
||||
currentToken = current;
|
||||
out = new ParsedTypeStatement(ScriptTextSpan(start, end, current->GetSpan().GetScriptName()), isConst, isArray,
|
||||
isHandle, scopedIdentifier);
|
||||
|
|
Loading…
Reference in New Issue