summary refs log tree commit diff stats
path: root/tests/ccgbugs
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-09-09 07:32:03 +0200
committerGitHub <noreply@github.com>2020-09-09 07:32:03 +0200
commit10988d48407e96b707b28c5900fcb0e59354e00a (patch)
treeb214c60feeec87fcec7393a5e81159e719fd2085 /tests/ccgbugs
parentc49b88163c12d18506ef43e4d26abd5d76f68359 (diff)
downloadNim-10988d48407e96b707b28c5900fcb0e59354e00a.tar.gz
borrow checking (#15282)
* refactoring: move procs to typeallowed.nim
* frontend preparations for first class openArray support
* prepare the code generator for first class openArray
* code generation for first class openArray; WIP
* code generation for open arrays, progress
* added isViewType proc
* preparations for borrow checking
* added borrow checking to the front end
Diffstat (limited to 'tests/ccgbugs')
-rw-r--r--tests/ccgbugs/tviews1.nim27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ccgbugs/tviews1.nim b/tests/ccgbugs/tviews1.nim
new file mode 100644
index 000000000..3ce0bb6d8
--- /dev/null
+++ b/tests/ccgbugs/tviews1.nim
@@ -0,0 +1,27 @@
+discard """
+  output: '''11
+22
+33
+3
+2
+3'''
+  targets: "c cpp"
+"""
+
+{.experimental: "views".}
+
+proc take(a: openArray[int]) =
+  echo a.len
+
+proc main(s: seq[int]) =
+  var x: openArray[int] = s
+  for i in 0 .. high(x):
+    echo x[i]
+  take(x)
+
+  take(x.toOpenArray(0, 1))
+  let y = x
+  take y
+
+
+main(@[11, 22, 33])