init checks and 'out' parameters (#14521)
* I don't care about observable stores * enforce explicit initializations * cleaner code for the stdlib * stdlib: use explicit initializations * make tests green * algorithm.nim: set result explicitly * remove out parameters and bring the PR into a mergable state * updated the changelog
This commit is contained in:
parent
a9eee6db65
commit
da29222f86
53 changed files with 355 additions and 257 deletions
|
|
@ -1767,6 +1767,7 @@ export iterators
|
|||
proc find*[T, S](a: T, item: S): int {.inline.}=
|
||||
## Returns the first index of `item` in `a` or -1 if not found. This requires
|
||||
## appropriate `items` and `==` operations to work.
|
||||
result = 0
|
||||
for i in items(a):
|
||||
if i == item: return
|
||||
inc(result)
|
||||
|
|
@ -2105,7 +2106,7 @@ when not defined(js):
|
|||
# Linux 64bit system. -- That's because the stack direction is the other
|
||||
# way around.
|
||||
when declared(nimGC_setStackBottom):
|
||||
var locals {.volatile.}: pointer
|
||||
var locals {.volatile, noinit.}: pointer
|
||||
locals = addr(locals)
|
||||
nimGC_setStackBottom(locals)
|
||||
|
||||
|
|
@ -2274,7 +2275,9 @@ when notJSnotNims:
|
|||
of 2: d = uint(cast[ptr uint16](a + uint(n.offset))[])
|
||||
of 4: d = uint(cast[ptr uint32](a + uint(n.offset))[])
|
||||
of 8: d = uint(cast[ptr uint64](a + uint(n.offset))[])
|
||||
else: sysAssert(false, "getDiscriminant: invalid n.typ.size")
|
||||
else:
|
||||
d = 0'u
|
||||
sysAssert(false, "getDiscriminant: invalid n.typ.size")
|
||||
return d
|
||||
|
||||
proc selectBranch(aa: pointer, n: ptr TNimNode): ptr TNimNode =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue