Skip to content

Commit

Permalink
Add error message for RunError::CannotIndexValue
Browse files Browse the repository at this point in the history
  • Loading branch information
doonv committed Jan 20, 2024
1 parent 85e91e3 commit 41de567
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/builtin_parser/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn eval_expression(
match reflect.reflect_mut() {
ReflectMut::Enum(dyn_enum) => {
let TypeInfo::Enum(enum_info) = registeration.type_info() else {
unreachable!();
unreachable!()
};
let Spanned { span, value } = *value_expr;
match value {
Expand Down Expand Up @@ -565,7 +565,7 @@ fn eval_member_expression(

Ok(Value::Resource(resource))
}
_ => Err(RunError::CannotIndexValue(left_span)),
_ => Err(RunError::CannotIndexValue(left_span.wrap(left))),
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/builtin_parser/runner/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum RunError {
},
VariableNotFound(Spanned<String>),
ExpectedNumberAfterUnaryOperator(Spanned<Value>),
CannotIndexValue(Span),
CannotIndexValue(Spanned<Value>),
FieldNotFoundInStruct(Span),
ReferenceToMovedData(Span),
VariableMoved(Spanned<String>),
Expand Down Expand Up @@ -74,7 +74,7 @@ impl RunError {
Custom { span, .. } => vec![span.clone()],
VariableNotFound(Spanned { span, .. }) => vec![span.clone()],
ExpectedNumberAfterUnaryOperator(Spanned { span, .. }) => vec![span.clone()],
CannotIndexValue(span) => vec![span.clone()],
CannotIndexValue(Spanned { span, .. }) => vec![span.clone()],
FieldNotFoundInStruct(span) => vec![span.clone()],
CannotDereferenceValue(Spanned { span, .. }) => vec![span.clone()],
ReferenceToMovedData(span) => vec![span.clone()],
Expand Down Expand Up @@ -115,7 +115,9 @@ impl RunError {
value.natural_kind()
)
.into(),
CannotIndexValue(_) => todo!(),
CannotIndexValue(Spanned { span: _, value }) => {
format!("Cannot index {} with a member expression.", value.kind()).into()
}
FieldNotFoundInStruct(_) => todo!(),
ReferenceToMovedData(_) => todo!(),
VariableMoved(Spanned { value, .. }) => format!("Variable `{value}` was moved.").into(),
Expand Down

0 comments on commit 41de567

Please sign in to comment.