bugfix list index
This commit is contained in:
parent
ec8fe5a795
commit
9ee8f193aa
3 changed files with 4 additions and 3 deletions
|
|
@ -163,7 +163,8 @@ let c = b + "world"
|
||||||
```
|
```
|
||||||
|
|
||||||
**dates and time**
|
**dates and time**
|
||||||
Create a date literal with
|
|
||||||
|
Create a date with a literal:
|
||||||
```
|
```
|
||||||
let d:date = d"1979-12-16 16:12:19.000 +01:00"
|
let d:date = d"1979-12-16 16:12:19.000 +01:00"
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn index_in_list_literal() {
|
fn index_in_list_literal() {
|
||||||
assert_eq!(run(r#"["abc","def"][0]"#), Ok(Value::String("abc".into())))
|
assert_eq!(run(r#"["abc","def"][1]"#), Ok(Value::String("def".into())))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ impl Vm {
|
||||||
OP_LIST_GET => {
|
OP_LIST_GET => {
|
||||||
let index_high = self.read(chunk);
|
let index_high = self.read(chunk);
|
||||||
let index_low = self.read(chunk);
|
let index_low = self.read(chunk);
|
||||||
let index = index_high <<16 + index_low;
|
let index = (index_high <<16) + index_low;
|
||||||
let list = self.pop();
|
let list = self.pop();
|
||||||
if let Value::List(list) = list {
|
if let Value::List(list) = list {
|
||||||
self.push(list.get(index).cloned().unwrap())
|
self.push(list.get(index).cloned().unwrap())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue