Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions _testdata/bug26/bug26.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Thank you to Matthew R Kasun for reporting this issue!
// See https://github.com/bobg/mingo/issues/26

package main

import (
"fmt"
"text/template/parse"
)

func main() {
foo := parse.BreakNode{}
fmt.Print(foo)
}
3 changes: 3 additions & 0 deletions _testdata/bug26/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module bug26

go 1.18
3 changes: 3 additions & 0 deletions expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ func (p *pkgScanner) funcBody(body *ast.BlockStmt) (bool, error) {
}

func (p *pkgScanner) compositeLit(lit *ast.CompositeLit) (bool, error) {
if isMax, err := p.expr(lit.Type); err != nil || isMax {
return isMax, err
}
for _, elt := range lit.Elts {
if isMax, err := p.expr(elt); err != nil || isMax {
return isMax, err
Expand Down
5 changes: 5 additions & 0 deletions history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func TestHistory(t *testing.T) {
pkgpath: "io",
ident: "NopCloser",
want: 16,
}, {
// https://github.com/bobg/mingo/issues/26
pkgpath: "text/template/parse",
ident: "BreakNode",
want: 18,
}}

for _, tc := range cases {
Expand Down
11 changes: 11 additions & 0 deletions regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ func TestBug14(t *testing.T) {
t.Errorf("got %d, want 16", v)
}
}

func TestBug26(t *testing.T) {
var s Scanner
res, err := s.ScanDir("_testdata/bug26")
if err != nil {
t.Fatal(err)
}
if v := res.Version(); v != 18 {
t.Errorf("got %d, want 18", v)
}
}