Better error message if type is not indexable with type
This commit is contained in:
parent
86447d0a36
commit
2787d947b5
|
@ -427,8 +427,7 @@ namespace Upsilon.Binder
|
|||
case Type.String when index.Type == Type.Number:
|
||||
return new BoundIndexExpression(expression, index, Type.String);
|
||||
default:
|
||||
//TODO: wrong type diagnostic
|
||||
throw new Exception(expression.Type.ToString());
|
||||
\ _diagnostics.LogInvalidIndexExpression(expression.Type, index.Type, e.Span);
|
||||
return new BoundLiteralExpression(new LuaNull());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@ namespace Upsilon
|
|||
{
|
||||
LogError($"Cannot convert type '{actualType}' to '{expectedType}'", span);
|
||||
}
|
||||
|
||||
public void LogInvalidIndexExpression(Type expressionType, Type indexType, TextSpan span)
|
||||
{
|
||||
LogError($"Cannot index type '{expressionType}' with type '{indexType}'", span);
|
||||
}
|
||||
}
|
||||
|
||||
public class DiagnosticsMessage
|
||||
|
|
Loading…
Reference in New Issue