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.

Reply via email to