I suspect that you've just run into some variation on
https://github.com/golang/go/issues/27378

Giovanni/Daniel/others better placed might be able to confirm more
precisely however.


On Mon, 3 Sep 2018 at 17:49, <ama...@naucera.net> wrote:
>
> Hi all,
>
> Since Go 1.11, the following test seems to pass when I would expect it to 
> panic with index out of range:
>
> package weirdness
>
> import "testing"
>
>
> type S []int
>
> func (s *S) Last() int {
>     return (*s)[len(*s) - 1]
> }
>
>
> func TestWeirdness(t *testing.T) {
>     var s S
>
>     defer func() {}()
>
>     s.Last()
> }
>
> Strangely, if the declaration of the s variable is moved below the defer, it 
> panics as expected. Any idea what’s going on?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to