Skip to content

Commit

Permalink
Test method bundles providing 'let' and 'inout' variants
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Aug 16, 2024
1 parent 23c6ee0 commit be0f6b2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Tests/EndToEndTests/TestCases/MethodBundle.hylo
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,27 @@ type A: Deinitializable {

}

public type B: Deinitializable {

public let x: Int

public memberwise init

public fun foo(_ n: sink Int) {
let { B(x: n) }
inout { &self.x = n }
}

}

public fun main() {
var a = A(x: 42)
precondition(a.foo().1 == 42)
precondition(a.foo().1 == 42)

var b0 = B(x: 1)
let b1 = b0.foo(2)
precondition(b1.x == 2)
&b0.foo(3)
precondition(b0.x == 3)
}

0 comments on commit be0f6b2

Please sign in to comment.