bpr / vla

Variable length arrays for Nim
Other
17 stars 1 forks source link

invalid pragma: unchecked #2

Open HJarausch opened 3 years ago

HJarausch commented 3 years ago

Using vla with Nim devel (GIT 2021-02-22) doesn't compile

vla.nim(6, 19) Error: invalid pragma: unchecked

bpr commented 3 years ago

Please try it now.

HJarausch commented 3 years ago

Thanks! In addition to your patch, I have applied the following patch

 template asOpenArray*[T](a: VarLengthArray[T]): openarray[T] =
-  cast[seq[type(a[0])]](a)
+  toOpenArray(addr a.data[0],0,a.len)

using the new? toOpenArray function from system.nim

I am pondering about adding a VarLengthArray which lives on the heap. Probably one has to use create and dealloc

bpr commented 3 years ago

Thanks, I'll make that change as soon as I have some time. Also, it's come to my attention that the test suite is deficient. Oh, BTW, PRs are welcome!