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:
|
case Type.String when index.Type == Type.Number:
|
||||||
return new BoundIndexExpression(expression, index, Type.String);
|
return new BoundIndexExpression(expression, index, Type.String);
|
||||||
default:
|
default:
|
||||||
//TODO: wrong type diagnostic
|
\ _diagnostics.LogInvalidIndexExpression(expression.Type, index.Type, e.Span);
|
||||||
throw new Exception(expression.Type.ToString());
|
|
||||||
return new BoundLiteralExpression(new LuaNull());
|
return new BoundLiteralExpression(new LuaNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,11 @@ namespace Upsilon
|
||||||
{
|
{
|
||||||
LogError($"Cannot convert type '{actualType}' to '{expectedType}'", span);
|
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
|
public class DiagnosticsMessage
|
||||||
|
|
Loading…
Reference in New Issue