Skip to content

Commit

Permalink
tests: add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbina committed Sep 11, 2024
1 parent 1ef8552 commit 7bf1369
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
discard """
description: '''
Ensure a view borrowing from the first parameter can be safely returned
from a procedure.
'''
targets: c js vm
knownIssue.js vm: "The first parameter isn't passed by reference"
"""

block direct_lent_view_primitive:
# test borrowing from primitive-type parameter with a direct view
proc test(x: int): lent int =
x

var x = 0
doAssert addr(test(x)) == addr(x)

block object_lent_view_primitive:
# test borrowing from primitive-type parameter with an indirect view
type Object = object
x: lent int

proc test(x: int): Object =
Object(x: x)

var x = 0
doAssert addr(test(x).x) == addr(x)

0 comments on commit 7bf1369

Please sign in to comment.