diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-09-09 14:19:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 14:19:22 +0200 |
commit | 217675cf84dc47bb68f03b341aff14315804efec (patch) | |
tree | af3b9d561a75a2cadc71de1e45beab310549b587 /tests | |
parent | ccd77b42af11e53631bee7bd74e16d39538541c9 (diff) | |
download | Nim-217675cf84dc47bb68f03b341aff14315804efec.tar.gz |
borrow checking refinements (#15290)
* added basic borrowing test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/effects/tcannot_borrow.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/effects/tcannot_borrow.nim b/tests/effects/tcannot_borrow.nim new file mode 100644 index 000000000..699176b04 --- /dev/null +++ b/tests/effects/tcannot_borrow.nim @@ -0,0 +1,18 @@ +discard """ + errormsg: "cannot borrow" + nimout: '''tcannot_borrow.nim(16, 7) Error: cannot borrow meh; what it borrows from is potentially mutated +tcannot_borrow.nim(17, 3) the mutation is here +tcannot_borrow.nim(16, 7) is the statement that connected the mutation to the parameter''' + line: 16 +""" + +{.experimental: "views".} + +type + Foo = object + field: string + +proc dangerous(s: var seq[Foo]) = + let meh: lent Foo = s[0] + s.setLen 0 + echo meh.field |