compiler: support creating pointers to struct
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
00671deb8f
commit
eb047b12a7
2 changed files with 52 additions and 5 deletions
18
pkg/compiler/pointer_test.go
Normal file
18
pkg/compiler/pointer_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package compiler_test
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAddressOfLiteral(t *testing.T) {
|
||||
src := `package foo
|
||||
type Foo struct { A int }
|
||||
func Main() int {
|
||||
f := &Foo{}
|
||||
setA(f, 3)
|
||||
return f.A
|
||||
}
|
||||
func setA(s *Foo, a int) { s.A = a }`
|
||||
eval(t, src, big.NewInt(3))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue