You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example about the openArray view type from the manual does not compile.
Example
{.experimental: "views".}
proctake(a: openArray[int]) =echo a.len
procmain(s: seq[int]) =var x: openArray[int] = s # 'x' is a view into 's'# it is checked that 'x' does not outlive 's' and# that 's' is not mutated.for i in0..high(x):
echo x[i]
take(x)
take(x.toOpenArray(0, 1)) # slicing remains possiblelet y = x # create a view from a viewtake y
# it is checked that 'y' does not outlive 'x' and# that 'x' is not mutated as long as 'y' lives.main(@[11, 22, 33])
Current Output
Error: 'y' borrows from location 'x' which does not live long enough
Expected Output
11
22
33
3
2
3
Compiler Version
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-01-27
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: e1129749207d25597e81fe06cd7e3099b5ecb61e
active boot switches: -d:danger
The text was updated successfully, but these errors were encountered:
The following example about the
openArray
view type from the manual does not compile.Example
Current Output
Expected Output
Compiler Version
The text was updated successfully, but these errors were encountered: