Better diagnostics for CantIndex error message
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-09-12 17:16:11 +02:00
parent ff4af34478
commit bd9eac9056
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 3 additions and 3 deletions

View File

@ -730,7 +730,7 @@ namespace Porygon::Binder {
auto indexerType = indexer->GetType();
if (!indexerType->CanBeIndexedWith(index->GetType().get())) {
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, index->GetStartPosition(),
index->GetLength());
index->GetLength(), {indexerType->ToString(), index->GetType()->ToString()});
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
}
if (indexerType->GetClass() == TypeClass::UserData) {
@ -764,7 +764,7 @@ namespace Porygon::Binder {
const auto &indexerType = indexer->GetType();
if (!indexerType->CanBeIndexedWithIdentifier(identifier.GetHash())) {
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, expression->GetStartPosition(),
expression->GetLength());
expression->GetLength(), {indexerType->ToString(), identifier.GetDebugString()});
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
}
if (indexerType->GetClass() == TypeClass::UserData) {

View File

@ -13,7 +13,7 @@ namespace Porygon::Diagnostics {
{DiagnosticCode ::CantAssignVariable, "Something went wrong while assigning variable."},
{DiagnosticCode ::VariableNotFound, "Variable not found."},
{DiagnosticCode ::ExpressionIsNotAFunction, "Called expression is not a function."},
{DiagnosticCode ::CantIndex, "Unable to index value."},
{DiagnosticCode ::CantIndex, "Unable to index type {0} with {1}."},
{DiagnosticCode ::InvalidReturnType, "Invalid return type."},
{DiagnosticCode ::ConditionNotABool, "A condition should return a bool."},
{DiagnosticCode ::InvalidTableValueType, "This is an invalid table value type."},