Skip to content

Commit accbd26

Browse files
committed
remove unnecessary number check and improve error message
1 parent 3f8c6d3 commit accbd26

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

dsc_lib/src/parser/expressions.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,8 @@ impl Expression {
131131
},
132132
Accessor::Index(index) => {
133133
if let Some(array) = value.as_array() {
134-
if !index.is_number() {
135-
return Err(DscError::Parser("Index is not a number".to_string()));
136-
}
137134
let Some(index) = index.as_u64() else {
138-
return Err(DscError::Parser("Index is not a number".to_string()));
135+
return Err(DscError::Parser("Index is not a valid number".to_string()));
139136
};
140137
let index = usize::try_from(index)?;
141138
if index >= array.len() {

0 commit comments

Comments
 (0)