Skip to content

Commit

Permalink
fix: handle index expression on binary string type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes authored and traefiker committed Nov 19, 2019
1 parent 08a37fc commit 56bec97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions _test/str3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import "strconv"

func main() {
str := strconv.Itoa(101)
println(str[0] == '1')
}

// Output:
// true
6 changes: 5 additions & 1 deletion interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 56bec97

Please sign in to comment.