Log error when variable is unknown type.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-01-09 14:12:09 +01:00
parent 0fbca3f01e
commit ce3d92e0a5
2 changed files with 10 additions and 3 deletions

View File

@@ -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(),