~mna/snow

snow/pkg/codegen/testdata/fn_interface_with_ref_method.snow.notyet -rw-r--r-- 336 bytes
424066c5Martin Angers doc: v0.0.5 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
interface I {
  fn foo()
}

struct S {
  var i: int 
  ref fn foo() {
    i = i + 1
  }
}

fn main() {
  var s = S(i: 0)
  let iface: I = s
  iface.foo()
  println(s.i)

  # this should work, s is mutable
  let tup: (int, I) = (1, s)
  tup.1.foo()
  println(s.i)
}

@extern(import: "fmt", symbol: "Println")
fn println(v: int)

#=1
#=2