Better diagnostics for CantIndex error message
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
ff4af34478
commit
bd9eac9056
|
@ -730,7 +730,7 @@ namespace Porygon::Binder {
|
||||||
auto indexerType = indexer->GetType();
|
auto indexerType = indexer->GetType();
|
||||||
if (!indexerType->CanBeIndexedWith(index->GetType().get())) {
|
if (!indexerType->CanBeIndexedWith(index->GetType().get())) {
|
||||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, index->GetStartPosition(),
|
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());
|
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||||
}
|
}
|
||||||
if (indexerType->GetClass() == TypeClass::UserData) {
|
if (indexerType->GetClass() == TypeClass::UserData) {
|
||||||
|
@ -764,7 +764,7 @@ namespace Porygon::Binder {
|
||||||
const auto &indexerType = indexer->GetType();
|
const auto &indexerType = indexer->GetType();
|
||||||
if (!indexerType->CanBeIndexedWithIdentifier(identifier.GetHash())) {
|
if (!indexerType->CanBeIndexedWithIdentifier(identifier.GetHash())) {
|
||||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, expression->GetStartPosition(),
|
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, expression->GetStartPosition(),
|
||||||
expression->GetLength());
|
expression->GetLength(), {indexerType->ToString(), identifier.GetDebugString()});
|
||||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||||
}
|
}
|
||||||
if (indexerType->GetClass() == TypeClass::UserData) {
|
if (indexerType->GetClass() == TypeClass::UserData) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Porygon::Diagnostics {
|
||||||
{DiagnosticCode ::CantAssignVariable, "Something went wrong while assigning variable."},
|
{DiagnosticCode ::CantAssignVariable, "Something went wrong while assigning variable."},
|
||||||
{DiagnosticCode ::VariableNotFound, "Variable not found."},
|
{DiagnosticCode ::VariableNotFound, "Variable not found."},
|
||||||
{DiagnosticCode ::ExpressionIsNotAFunction, "Called expression is not a function."},
|
{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 ::InvalidReturnType, "Invalid return type."},
|
||||||
{DiagnosticCode ::ConditionNotABool, "A condition should return a bool."},
|
{DiagnosticCode ::ConditionNotABool, "A condition should return a bool."},
|
||||||
{DiagnosticCode ::InvalidTableValueType, "This is an invalid table value type."},
|
{DiagnosticCode ::InvalidTableValueType, "This is an invalid table value type."},
|
||||||
|
|
Loading…
Reference in New Issue