diff --git a/_test/str3.go b/_test/str3.go new file mode 100644 index 000000000..a468da344 --- /dev/null +++ b/_test/str3.go @@ -0,0 +1,11 @@ +package main + +import "strconv" + +func main() { + str := strconv.Itoa(101) + println(str[0] == '1') +} + +// Output: +// true diff --git a/interp/cfg.go b/interp/cfg.go index 8e9530a85..26ecef64e 100644 --- a/interp/cfg.go +++ b/interp/cfg.go @@ -634,7 +634,11 @@ func (interp *Interpreter) cfg(root *node) ([]*node, error) { case stringT: n.typ = sc.getType("byte") case valueT: - n.typ = &itype{cat: valueT, rtype: t.rtype.Elem()} + if t.rtype.Kind() == reflect.String { + n.typ = sc.getType("byte") + } else { + n.typ = &itype{cat: valueT, rtype: t.rtype.Elem()} + } default: n.typ = t.val }