mirror of
https://github.com/golang/go
synced 2024-11-24 22:27:57 -07:00
simple fix to not have 'exp/eval' panic in presence of slices like s[:2]
R=golang-dev, gri CC=binet, golang-dev https://golang.org/cl/3782044
This commit is contained in:
parent
03e259664f
commit
33145c4868
@ -595,9 +595,15 @@ func (a *exprCompiler) compile(x ast.Expr, callCtx bool) *expr {
|
||||
return ei.compileIndexExpr(l, r)
|
||||
|
||||
case *ast.SliceExpr:
|
||||
var hi *expr
|
||||
var lo, hi *expr
|
||||
arr := a.compile(x.X, false)
|
||||
lo := a.compile(x.Index, false)
|
||||
if x.Index == nil {
|
||||
// beginning was omitted, so we need to provide it
|
||||
ei := &exprInfo{a.compiler, x.Pos()}
|
||||
lo = ei.compileIntLit("0")
|
||||
} else {
|
||||
lo = a.compile(x.Index, false)
|
||||
}
|
||||
if x.End == nil {
|
||||
// End was omitted, so we need to compute len(x.X)
|
||||
ei := &exprInfo{a.compiler, x.Pos()}
|
||||
|
Loading…
Reference in New Issue
Block a user