diff --git a/interp/cfg.go b/interp/cfg.go index cb7da805c..050432cf8 100644 --- a/interp/cfg.go +++ b/interp/cfg.go @@ -740,7 +740,13 @@ func (interp *Interpreter) cfg(root *node, importPath string) ([]*node, error) { wireChild(n) t := n.child[0].typ switch t.cat { - case aliasT, ptrT: + case aliasT: + if isString(t.val.TypeOf()) { + n.typ = sc.getType("byte") + break + } + fallthrough + case ptrT: n.typ = t.val if t.val.cat == valueT { n.typ = &itype{cat: valueT, rtype: t.val.rtype.Elem()} diff --git a/interp/interp_eval_test.go b/interp/interp_eval_test.go index 61674721d..f604d4886 100644 --- a/interp/interp_eval_test.go +++ b/interp/interp_eval_test.go @@ -457,6 +457,7 @@ func TestEvalSliceExpression(t *testing.T) { {src: `a := []int{0,1,2,3}[1::4]`, err: "1:49: 2nd index required in 3-index slice"}, {src: `a := []int{0,1,2,3}[1:3:]`, err: "1:51: 3rd index required in 3-index slice"}, {src: `a := []int{0,1,2}[3:1]`, err: "invalid index values, must be low <= high <= max"}, + {pre: func() { eval(t, i, `type Str = string; var r Str = "truc"`) }, src: `r[1]`, res: "114"}, }) }