Skip to content

Commit 211ae69

Browse files
committedNov 6, 2019
Fix checker for string slices.
1 parent 4d2b11c commit 211ae69

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
 

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v1.3.2
4+
* Fixed checker for string slices.
5+
36
## v1.3.1
47
* Moved `conf.Options` out of internal package.
58

‎checker/checker.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ func (v *visitor) IndexNode(node *ast.IndexNode) reflect.Type {
292292
func (v *visitor) SliceNode(node *ast.SliceNode) reflect.Type {
293293
t := v.visit(node.Node)
294294

295-
if _, ok := indexType(t); ok {
295+
_, isIndex := indexType(t)
296+
297+
if isIndex || isString(t) {
296298
if node.From != nil {
297299
from := v.visit(node.From)
298300
if !isInteger(from) {

‎expr_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,10 @@ func TestExpr(t *testing.T) {
780780
`Variadic("empty")`,
781781
[]int{},
782782
},
783+
{
784+
`String[:3]`,
785+
"str",
786+
},
783787
}
784788

785789
for _, tt := range tests {

0 commit comments

Comments
 (0)