From bae3e9257777fba79b95081d1b8b6f7e89f06467 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 12 Sep 2019 18:25:18 +0200 Subject: [PATCH] Better error handling when variable is not found --- src/Binder/Binder.cpp | 2 +- src/Diagnostics/ErrorMessages-EN-US.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Binder/Binder.cpp b/src/Binder/Binder.cpp index 504073d..c770c5b 100644 --- a/src/Binder/Binder.cpp +++ b/src/Binder/Binder.cpp @@ -406,7 +406,7 @@ namespace Porygon::Binder { if (scope == -1) { this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::VariableNotFound, expression->GetStartPosition(), - expression->GetLength()); + expression->GetLength(), {key.GetDebugString()}); return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength()); } auto var = this->_scope->GetVariable(scope, key); diff --git a/src/Diagnostics/ErrorMessages-EN-US.cpp b/src/Diagnostics/ErrorMessages-EN-US.cpp index 40b00ee..d550712 100644 --- a/src/Diagnostics/ErrorMessages-EN-US.cpp +++ b/src/Diagnostics/ErrorMessages-EN-US.cpp @@ -11,7 +11,7 @@ namespace Porygon::Diagnostics { {DiagnosticCode ::NoBinaryOperationFound, "No binary operation found for these operands and operator."}, {DiagnosticCode ::NoUnaryOperationFound, "No unary operation found for this operand and operator."}, {DiagnosticCode ::CantAssignVariable, "Something went wrong while assigning variable."}, - {DiagnosticCode ::VariableNotFound, "Variable not found."}, + {DiagnosticCode ::VariableNotFound, "Variable '{0}' not found."}, {DiagnosticCode ::ExpressionIsNotAFunction, "Called expression is not a function."}, {DiagnosticCode ::CantIndex, "Unable to index type {0} with {1}."}, {DiagnosticCode ::InvalidReturnType, "Invalid return type."},