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
10package main
11
12import "math"
13
14type Vec2 [2]float64
15
16func main() {
17	var a Vec2
18	a.A().B().C().D()
19}
20
21func (v Vec2) A() Vec2 {
22	return Vec2{v[0], v[0]}
23}
24
25func (v Vec2) B() Vec2 {
26	return Vec2{1.0 / v.D(), 0}
27}
28
29func (v Vec2) C() Vec2 {
30	return Vec2{v[0], v[0]}
31}
32
33func (v Vec2) D() float64 {
34	return math.Sqrt(v[0])
35}
36