fix #19862; make widestrs consistent between refc and orc (#19874) [backport]

fix #19862; make widestrs consistent in refc and orc
This commit is contained in:
flywind 2022-06-09 22:51:17 +08:00 • committed by GitHub
commit 1972005439
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -224,3 +224,6 @@ when defined(nimv2):
proc `$`*(s: WideCStringObj): string = proc `$`*(s: WideCStringObj): string =
$(s.data) $(s.data)
proc len*(w: WideCStringObj): int {.inline.} =
len(w.data)

13
tests/arc/t19862.nim Normal file
View file

@ -0,0 +1,13 @@
discard """
matrix: "--gc:refc; --gc:arc"
"""
# bug #19862
type NewString = object
proc len(s: NewString): int = 10
converter toNewString(x: WideCStringObj): NewString = discard
let w = newWideCString("test")
doAssert len(w) == 4