parser: make [..] work (#11064)
parent
c30cda3daf
commit
8d2567740b
|
@ -2208,7 +2208,12 @@ fn (mut p Parser) index_expr(left ast.Expr) ast.IndexExpr {
|
|||
has_low = false
|
||||
// [..end]
|
||||
p.next()
|
||||
high := p.expr(0)
|
||||
mut high := ast.empty_expr()
|
||||
mut has_high := false
|
||||
if p.tok.kind != .rsbr {
|
||||
high = p.expr(0)
|
||||
has_high = true
|
||||
}
|
||||
pos := start_pos.extend(p.tok.position())
|
||||
p.check(.rsbr)
|
||||
return ast.IndexExpr{
|
||||
|
@ -2217,7 +2222,7 @@ fn (mut p Parser) index_expr(left ast.Expr) ast.IndexExpr {
|
|||
index: ast.RangeExpr{
|
||||
low: ast.empty_expr()
|
||||
high: high
|
||||
has_high: true
|
||||
has_high: has_high
|
||||
pos: pos
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,3 +18,10 @@ fn test_for_in_shared_array_named_array() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_fixed_array_to_dynamic_array() {
|
||||
y := [1, 2, 3]!
|
||||
mut x := y[..]
|
||||
x << 4
|
||||
assert x.len == 4
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue