Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text/cmd/gotext: Error extracting constant text from other files #64842

Open
mzmuer opened this issue Dec 22, 2023 · 2 comments
Open

x/text/cmd/gotext: Error extracting constant text from other files #64842

mzmuer opened this issue Dec 22, 2023 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mzmuer
Copy link

mzmuer commented Dec 22, 2023

Go version

go version go1.21.4 darwin/arm64

What operating system and processor architecture are you using (go env)?

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mzmuer/Library/Caches/go-build'
GOENV='/Users/mzmuer/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mzmuer/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mzmuer/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/mzmuer/go/src/duo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/mg/q1vk2hwj5n5gyskll1kc7glc0000gn/T/go-build327130366=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

main.go

//go:generate gotext -srclang=en update -out=catalog.go -lang=en,zh test/...
func main() {
	p := message.NewPrinter(language.English)
	p.Sprintf(Val)
	return
}

Another file inside the same package other.go

const Val = "foo"

run

go generate ./...

What did you expect to see?

Correct extraction returns nothing. there will be no problem if const Val = "foo" is put into main.go file

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x100b7a764]

goroutine 1 [running]:
golang.org/x/text/message/pipeline.packageExtracter.handleCall({0x1400a870960?, 0x14000000a20?, 0x1400db22160?, 0x14039c67ef0?}, 0x1400ead9a80)
        /Users/mzmuer/go/pkg/mod/golang.org/x/text@v0.14.0/message/pipeline/extract.go:600 +0x1b4
golang.org/x/text/message/pipeline.(*extracter).extractMessages.func3({0x100ce86c8?, 0x1400ead9a80?})
        /Users/mzmuer/go/pkg/mod/golang.org/x/text@v0.14.0/message/pipeline/extract.go:545 +0x54
go/ast.inspector.Visit(0x1403967d200, {0x100ce86c8?, 0x1400ead9a80?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:386 +0x38
go/ast.Walk({0x100ce71e8?, 0x1403967d200?}, {0x100ce86c8?, 0x1400ead9a80?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:51 +0x4c
go/ast.walkExprList(...)
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:26
go/ast.Walk({0x100ce71e8?, 0x1403967d200?}, {0x100ce86c8?, 0x1400ead9b00?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:144 +0x19d0
go/ast.walkExprList(...)
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:26
go/ast.Walk({0x100ce71e8?, 0x1403967d200?}, {0x100ce8e98?, 0x14011edef60?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:226 +0x18a8
go/ast.walkStmtList(...)
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:32
go/ast.Walk({0x100ce71e8?, 0x1403967d200?}, {0x100ce84e8?, 0x14011ee2630?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:234 +0x184c
go/ast.Walk({0x100ce71e8?, 0x1403967d200?}, {0x100ce8678?, 0x14011ee2660?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:357 +0x13c4
go/ast.walkDeclList(...)
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:38
go/ast.Walk({0x100ce71e8?, 0x1403967d200?}, {0x100ce86f0?, 0x1400a870960?})
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:366 +0x154c
go/ast.Inspect(...)
        /opt/homebrew/opt/go/libexec/src/go/ast/walk.go:397
golang.org/x/text/message/pipeline.(*extracter).extractMessages(0x14000000a20)
        /Users/mzmuer/go/pkg/mod/golang.org/x/text@v0.14.0/message/pipeline/extract.go:542 +0x304
golang.org/x/text/message/pipeline.Extract(0x1400019e410)
        /Users/mzmuer/go/pkg/mod/golang.org/x/text@v0.14.0/message/pipeline/extract.go:50 +0x38
main.runUpdate(0x101096c20?, 0x14000020210?, {0x14000020230?, 0x100838be8?, 0x140000586e8?})
        /Users/mzmuer/go/pkg/mod/golang.org/x/text@v0.14.0/cmd/gotext/update.go:31 +0x4c
main.main()
        /Users/mzmuer/go/pkg/mod/golang.org/x/text@v0.14.0/cmd/gotext/main.go:158 +0x334
pkg/i18n/i18n.go:9: running "gotext": exit status 2

@gopherbot gopherbot added this to the Unreleased milestone Dec 22, 2023
@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 28, 2023
@dr2chase
Copy link
Contributor

@mpvl , you're the nominal owner of x/text, do you have time to look at this or suggest someone else who might be able?

@Succo
Copy link

Succo commented Feb 6, 2024

Looks like a duplicate of #60555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants