don't use {.rtl.} for generics, otherwise -d:useNimRtl gives ambiguous identifier nimrtl error (#18406)
This commit is contained in:
parent
41c29cb3a1
commit
779b4e307b
3 changed files with 13 additions and 10 deletions
|
|
@ -1760,7 +1760,7 @@ func join*(a: openArray[string], sep: string = ""): string {.rtl,
|
||||||
else:
|
else:
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
func join*[T: not string](a: openArray[T], sep: string = ""): string {.rtl.} =
|
func join*[T: not string](a: openArray[T], sep: string = ""): string =
|
||||||
## Converts all elements in the container `a` to strings using `$`,
|
## Converts all elements in the container `a` to strings using `$`,
|
||||||
## and concatenates them with `sep`.
|
## and concatenates them with `sep`.
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,13 @@ when defined(createNimRtl):
|
||||||
{.pragma: inl.}
|
{.pragma: inl.}
|
||||||
{.pragma: compilerRtl, compilerproc, exportc: "nimrtl_$1", dynlib.}
|
{.pragma: compilerRtl, compilerproc, exportc: "nimrtl_$1", dynlib.}
|
||||||
elif defined(useNimRtl):
|
elif defined(useNimRtl):
|
||||||
when defined(windows):
|
#[
|
||||||
const nimrtl* = "nimrtl.dll"
|
`{.rtl.}` should only be used for non-generic procs.
|
||||||
elif defined(macosx):
|
]#
|
||||||
const nimrtl* = "libnimrtl.dylib"
|
const nimrtl* =
|
||||||
else:
|
when defined(windows): "nimrtl.dll"
|
||||||
const nimrtl* = "libnimrtl.so"
|
elif defined(macosx): "libnimrtl.dylib"
|
||||||
|
else: "libnimrtl.so"
|
||||||
{.pragma: rtl, importc: "nimrtl_$1", dynlib: nimrtl, gcsafe.}
|
{.pragma: rtl, importc: "nimrtl_$1", dynlib: nimrtl, gcsafe.}
|
||||||
{.pragma: inl.}
|
{.pragma: inl.}
|
||||||
{.pragma: compilerRtl, compilerproc, importc: "nimrtl_$1", dynlib: nimrtl.}
|
{.pragma: compilerRtl, compilerproc, importc: "nimrtl_$1", dynlib: nimrtl.}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
discard """
|
discard """
|
||||||
output: "Done"
|
|
||||||
cmd: "nim $target --debuginfo --hints:on --define:useNimRtl $options $file"
|
cmd: "nim $target --debuginfo --hints:on --define:useNimRtl $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -37,5 +36,8 @@ proc eval(n: PNode): int =
|
||||||
for i in 0..100_000:
|
for i in 0..100_000:
|
||||||
discard eval(buildTree(2))
|
discard eval(buildTree(2))
|
||||||
|
|
||||||
echo "Done"
|
# bug https://forum.nim-lang.org/t/8176; Error: ambiguous identifier: 'nimrtl'
|
||||||
|
import std/strutils
|
||||||
|
doAssert join(@[1, 2]) == "12"
|
||||||
|
doAssert join(@[1.5, 2.5]) == "1.52.5"
|
||||||
|
doAssert join(@["a", "bc"]) == "abc"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue