Russ Cox | d2cc988 | 2012-02-16 23:50:37 -0500 | [diff] [blame] | 1 | // errorcheck |
Russ Cox | 4cf7711 | 2009-01-30 14:39:31 -0800 | [diff] [blame] | 2 | |
| 3 | // Copyright 2009 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 | |
Rob Pike | 83976e3 | 2012-02-19 14:28:53 +1100 | [diff] [blame] | 7 | // Verify that it is illegal to take the address of a function. |
| 8 | // Does not compile. |
| 9 | |
Russ Cox | 4cf7711 | 2009-01-30 14:39:31 -0800 | [diff] [blame] | 10 | package main |
| 11 | |
| 12 | var notmain func() |
| 13 | |
| 14 | func main() { |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 15 | var x = &main // ERROR "address of|invalid" |
| 16 | main = notmain // ERROR "assign to|invalid" |
Ian Lance Taylor | 387e7c2 | 2012-01-22 11:50:45 -0800 | [diff] [blame] | 17 | _ = x |
Russ Cox | 4cf7711 | 2009-01-30 14:39:31 -0800 | [diff] [blame] | 18 | } |