Don't allow indexing unregistered types on evaluation
This commit is contained in:
@@ -47,6 +47,17 @@ namespace Upsilon.Binder
|
||||
{
|
||||
innerScope = scopeOwner.EvaluationScope;
|
||||
}
|
||||
if (variable.Type == Type.Unknown)
|
||||
{
|
||||
throw new EvaluationException(state.Script.FileName,
|
||||
$"Variable of type '{variable.Type}' is not a registered type, and can't be indexed.", Span);
|
||||
}
|
||||
if (variable.Type == Type.UserData && variable.Type is UndefinedUserDataTypeContainer userDataTypeContainer)
|
||||
{
|
||||
throw new EvaluationException(state.Script.FileName,
|
||||
$"Variable of type '{userDataTypeContainer.UserData}' is not a registered type, and can't be indexed.", Span);
|
||||
}
|
||||
|
||||
|
||||
var indexer = Index.Evaluate(scope, diagnostics, ref state);
|
||||
return indexable.Get(diagnostics, Span, indexer, innerScope);
|
||||
@@ -87,6 +98,12 @@ namespace Upsilon.Binder
|
||||
$"Variable of type '{variable.Type}' is not indexable.", Span);
|
||||
}
|
||||
|
||||
if (variable.Type == Type.UserData && variable.Type is UndefinedUserDataTypeContainer userDataTypeContainer)
|
||||
{
|
||||
throw new EvaluationException(state.Script.FileName,
|
||||
$"Variable of type '{userDataTypeContainer.UserData}' is not a registered type, and can't be indexed.", Span);
|
||||
}
|
||||
|
||||
var innerScope = scope;
|
||||
if (variable is IScopeOwner scopeOwner)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user