From e39ff44d87fbbd04bad6b28a7ce3a4c1147547cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 7 Mar 2021 23:16:38 +0100 Subject: skip indexing into tuples when type checking --- src/vm.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/vm.rs') diff --git a/src/vm.rs b/src/vm.rs index 7cfc8d3..6b69b3c 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -717,6 +717,14 @@ impl VM { }; } + Op::Index => { + // We don't have any information about the slot and the indexable might contain + // mixed types. + self.stack.pop().unwrap(); // indexable + self.stack.pop().unwrap(); // slot + self.stack.push(Value::Unknown); + } + Op::Call(num_args) => { let new_base = self.stack.len() - 1 - num_args; match self.stack[new_base].clone() { -- cgit v1.2.1 From dc25e664305ed49edff4e45eaec6ed1fad910c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 8 Mar 2021 00:09:24 +0100 Subject: check index out of bounds correctly --- src/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/vm.rs') diff --git a/src/vm.rs b/src/vm.rs index 6b69b3c..1e04673 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -296,7 +296,7 @@ impl VM { match (val, slot) { (Value::Tuple(v), Value::Int(slot)) => { let slot = slot as usize; - if v.len() < slot { + if v.len() <= slot { self.stack.push(Value::Nil); let len = v.len(); error!(self, ErrorKind::IndexOutOfBounds(Value::Tuple(v), len, slot)); -- cgit v1.2.1 From f145fbd1d8ad6148c8c5631487d5208c043a0a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 8 Mar 2021 00:46:54 +0100 Subject: remove comment --- src/vm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/vm.rs') diff --git a/src/vm.rs b/src/vm.rs index 1e04673..2752435 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -720,8 +720,8 @@ impl VM { Op::Index => { // We don't have any information about the slot and the indexable might contain // mixed types. - self.stack.pop().unwrap(); // indexable - self.stack.pop().unwrap(); // slot + self.stack.pop().unwrap(); + self.stack.pop().unwrap(); self.stack.push(Value::Unknown); } -- cgit v1.2.1