diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index ba75af9f07..6414ae73ee 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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 } } diff --git a/vlib/v/tests/array_test.v b/vlib/v/tests/array_test.v index 5340fc46bf..d872ce384c 100644 --- a/vlib/v/tests/array_test.v +++ b/vlib/v/tests/array_test.v @@ -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 +}