cmd/compile: wrong line number for inlined defer function #21877
Labels
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
Does this issue reproduce with the latest release?
Not sure; reproduces on the playground.
What operating system and processor architecture are you using (
go env
)?Playground & locally:
What did you do?
Tried to get the line number on which a defer function call was made; unable to do so and instead get the line number for the end of the function (
}
)https://play.golang.org/p/PHvBl4RJaj
Note: if you write the defer as:
You get what you'd expect since the unnamed function
func1
is now considered to be at the end of of the function while thePrintStack()
itself is not deferred.What did you expect to see?
Stack trace similar to the one below but with the line number for main.test() to be 12 (the line the defer function was defined) instead of line 13 (where the function ends).
Seems to relate to #5856 where the fact that there are two lines of relevance for defers: where they are defined and where they are executed and there is a conundrum about how to either provide both or which to provide.
Not sure if this had been solved since then.
What did you see instead?
The text was updated successfully, but these errors were encountered: