Fixes for new runtime (#7037)
This commit is contained in:
parent
e2f1f8bafa
commit
fd1883f90a
2 changed files with 28 additions and 6 deletions
|
|
@ -7,7 +7,7 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
import allocators
|
||||
import allocators, typetraits
|
||||
|
||||
## Default seq implementation used by Nim's core.
|
||||
type
|
||||
|
|
@ -115,3 +115,25 @@ proc `@`*[T](elems: openArray[T]): seq[T] =
|
|||
result.data[i] = elems[i]
|
||||
|
||||
proc len*[T](x: seq[T]): int {.inline.} = x.len
|
||||
|
||||
proc `$`*[T](x: seq[T]): string =
|
||||
result = "@["
|
||||
var firstElement = true
|
||||
for i in 0..<x.len:
|
||||
let
|
||||
value = x.data[i]
|
||||
if firstElement:
|
||||
firstElement = false
|
||||
else:
|
||||
result.add(", ")
|
||||
|
||||
when compiles(value.isNil):
|
||||
# this branch should not be necessary
|
||||
if value.isNil:
|
||||
result.add "nil"
|
||||
else:
|
||||
result.addQuoted(value)
|
||||
else:
|
||||
result.addQuoted(value)
|
||||
|
||||
result.add("]")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue