Debian Codegraph @

test/fixedbugs/issue70189.go

raw
1 // run
2
3 // Copyright 2024 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 package main
8
9 func nan() float64 {
10 var x, y float64
11 return x / y
12 }
13
14 func main() {
15 m := map[float64]int{}
16
17 // Make a small map with nan keys
18 for i := 0; i < 8; i++ {
19 m[nan()] = i
20 }
21
22 // Start iterating on it.
23 start := true
24 for _, v := range m {
25 if start {
26 // Add some more elements.
27 for i := 0; i < 10; i++ {
28 m[float64(i)] = i
29 }
30 // Now clear the map.
31 clear(m)
32 start = false
33 } else {
34 // We should never reach here.
35 panic(v)
36 }
37 }
38 }