-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type conversion of distinct creates erroneous copy in VM #12282
Labels
Comments
narimiran
added
the
Hacktoberfest (Open)
Issues suitable for Hacktoberfest, open for working on.
label
Oct 1, 2019
I ran into a variation of the same bug. type
MyArr = distinct array[3,int]
proc foobar(dst: var array[3,int]) =
dst[0] = 1
dst[1] = 2
dst[2] = 3
proc test() =
var z: MyArr
foobar(array[3,int](z))
echo array[3,int](z)
test()
static:
test() output:
This is important since my rewrite of the json.to macro requires this to work. |
Closed
@Clyybber can you change the title to something like:
when true: #D20200424T162848:here
type Foo = distinct string
proc test() =
var s: Foo
s.string.add('c')
doAssert s.string == "c" #fails
static: test() borrow works:when true:
type Foo = distinct string
proc add(a: var Foo, b: char) {.borrow.}
proc test() =
var s: Foo
s.add('c')
doAssert s.string == "c" #ok
static: test() conversion TO distinct also failswhen true:
type Foo = distinct string
proc add(a: var Foo, b: char) {.borrow.}
proc test() =
var s: string
s.Foo.add('c')
doAssert s.string == "c" # fails
static: test() |
Clyybber
changed the title
var param with type conversion doesn't work in VM
type conversion of distinct creates erroneous copy in VM
Apr 25, 2020
Clyybber
removed
Easy
good first issue
Hacktoberfest (Open)
Issues suitable for Hacktoberfest, open for working on.
labels
Nov 15, 2020
see also example with seq from #9423 (comment), closing #9423 as duplicate of this |
timotheecour
added a commit
to timotheecour/Nim
that referenced
this issue
Mar 31, 2021
Araq
pushed a commit
that referenced
this issue
Mar 31, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiling the snippet below outputs an empty line, while it should output
c
Example
(EDIT) problem with distinct remains even after #15423 which deprecates
TaintedString
Current Output
Expected Output
EDIT: Example 2
see also example with seq in #9423 (comment)
Additional Information
The text was updated successfully, but these errors were encountered: