1// run 2 3// Copyright 2013 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// Bug in method values: escape analysis was off. 8 9package main 10 11import "sync" 12 13var called = false 14 15type T struct { 16 once sync.Once 17} 18 19func (t *T) M() { 20 called = true 21} 22 23func main() { 24 var t T 25 t.once.Do(t.M) 26 if !called { 27 panic("not called") 28 } 29} 30