-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fixes #25116; default(T) breaks requiresInit requirements #25153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
It's really annoying for let z: seq[range['a'..'z']] = @['c'] Otherwise stdlibs need a |
The stdlib should use more zeroDefault then, why would it need yet another trait. |
proc arrayWithDefault*[T](size: static int): array[size, T] {.noinit, nodestroy, raises: [].} =
## Creates a new array filled with `default(T)`.
for i in 0..size-1:
result[i] = default(T)
proc setLen[T](s: var seq[T], newlen: Natural) {.nodestroy.} =
...
for i in oldLen..<newlen:
xu.p.data[i] = default(T)
|
the only valid use of It also brings into light the bytes-to-type edge where a type MyType = object
v: range[2..3]
proc `=destroy`(v: var MyType) =
assert v in 2..3 This is a general problem with building collections in Nim in a world with semi-deterministic destructors - the naive approach of trying to ignore the bytes-to-type edge that was introduced in ORC has downstream effects on the soundness of other features - this is also why a correct Table implementation likely would be better of using a |
It seems that It can make do by making the low bound value the default value of range types, e.g., simple range types only, like The annoying cases are {.experimental: "views".}
proc split*(s: string, seps: set[char] = Whitespace,
maxsplit: int = -1): seq[openArray[char]] = |
fixes #25116