Debian Codegraph @

gcc/testsuite/go.test/test/fixedbugs/issue27961.go

raw
1 // run
2
3 // Copyright 2018 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 // Issue 27961: some optimizations generate OffPtr with wrong
8 // types, which causes invalid bytecode on Wasm.
9
10 package main
11
12 import "math"
13
14 type Vec2 [2]float64
15
16 func main() {
17 var a Vec2
18 a.A().B().C().D()
19 }
20
21 func (v Vec2) A() Vec2 {
22 return Vec2{v[0], v[0]}
23 }
24
25 func (v Vec2) B() Vec2 {
26 return Vec2{1.0 / v.D(), 0}
27 }
28
29 func (v Vec2) C() Vec2 {
30 return Vec2{v[0], v[0]}
31 }
32
33 func (v Vec2) D() float64 {
34 return math.Sqrt(v[0])
35 }