summaryrefslogtreecommitdiff
path: root/src/eval/mod.rs
diff options
context:
space:
mode:
authorMarmare314 <49279081+Marmare314@users.noreply.github.com>2023-04-28 18:49:21 +0200
committerGitHub <noreply@github.com>2023-04-28 18:49:21 +0200
commit8fa1af8ac85a9f5395b53139ac6bcc299d95f347 (patch)
treeb6eeaeef0870a5f8d2e4b6c5766d043e0e9a305f /src/eval/mod.rs
parent0d8c3254b75e6493ecf8efc46c37d049c1ae6b63 (diff)
check index on placeholder (#1005)
Diffstat (limited to 'src/eval/mod.rs')
-rw-r--r--src/eval/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 68163bf6..2719c298 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -1268,7 +1268,13 @@ impl ast::Pattern {
ast::DestructuringKind::Named(named) => {
bail!(named.span(), "cannot destructure named elements from an array")
}
- ast::DestructuringKind::Placeholder(_) => i += 1,
+ ast::DestructuringKind::Placeholder(underscore) => {
+ if i < value.len() {
+ i += 1
+ } else {
+ bail!(underscore.span(), "not enough elements to destructure")
+ }
+ }
}
}
if i < value.len() {