runtime: Caller
can return <autogenerated>
as filename when called from a global variable
#64520
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No, the issue appeared with 88cb17e (unreleased).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
When using the current dev version of Go,
runtime.Caller
can return<autogenerated>
as caller filename, instead of the actual caller filename.Minimal reproducible example can be found on https://github.com/pgimalac/gist/tree/go-runtime-caller-filename-autogenerated (I could not reduce it to a single file, but it's rather small as it is).
The example declares a global variable which indirectly calls
runtime.Caller
, which returns<autogenerated>
instead of the actual filename.A main function prints an error with the returned filename if it doesn't contain
package1
. It can run withgo run main.go
.If this is not considered a bug, the documentation should make it clear that
runtime.Caller
can return something else when called from a global variable.What did you expect to see?
runtime.Caller
should return<root>/mypackage1/myfile.go
.What did you see instead?
runtime.Caller
returns<autogenerated>
.The text was updated successfully, but these errors were encountered: