fix #12282 distinct now does not create erroneous copy in VM (#17594)

This commit is contained in:
Timothee Cour 2021-03-31 01:15:08 -07:00 • committed by GitHub
commit 8ee0eda841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 2 deletions

View file

@ -1,4 +1,5 @@
discard """
targets: "c js"
output: '''
tdistinct
25
@ -138,3 +139,34 @@ block tRequiresInit:
accept:
let s = "test"
doAssert s == "test"
type Foo = distinct string
template main() =
# xxx put everything here to test under RT + VM
block: # bug #12282
block:
proc test() =
var s: Foo
s.string.add('c')
doAssert s.string == "c" # was failing
test()
block:
proc add(a: var Foo, b: char) {.borrow.}
proc test() =
var s: Foo
s.add('c')
doAssert s.string == "c" # was ok
test()
block:
proc add(a: var Foo, b: char) {.borrow.}
proc test() =
var s: string
s.Foo.add('c')
doAssert s.string == "c" # was failing
test()
static: main()
main()