Log error when variable is unknown type.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user