Commit 20db0f42 authored by Robert Griesemer's avatar Robert Griesemer

go/ast: add Slice3 field to SliceExpr

If Slice3 is set, the expression is
a 3-index slice expression (2 colons).
Required for type-checking.

Backward-compatible API extension.

R=r, rsc
CC=golang-dev
https://golang.org/cl/13826050
parent b0ef6aef
......@@ -298,6 +298,7 @@ type (
Low Expr // begin of slice range; or nil
High Expr // end of slice range; or nil
Max Expr // maximum capacity of slice; or nil
Slice3 bool // true if 3-index slice (2 colons present)
Rbrack token.Pos // position of "]"
}
......
......@@ -1187,7 +1187,7 @@ func (p *parser) parseIndexOrSlice(x ast.Expr) ast.Expr {
if ncolons > 0 {
// slice expression
return &ast.SliceExpr{X: x, Lbrack: lbrack, Low: index[0], High: index[1], Max: index[2], Rbrack: rbrack}
return &ast.SliceExpr{X: x, Lbrack: lbrack, Low: index[0], High: index[1], Max: index[2], Slice3: ncolons == 2, Rbrack: rbrack}
}
return &ast.IndexExpr{X: x, Lbrack: lbrack, Index: index[0], Rbrack: rbrack}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment