Skip to content
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

VM fails when returning var char via var string #15464

Closed
metagn opened this issue Oct 2, 2020 · 1 comment · Fixed by #15987
Closed

VM fails when returning var char via var string #15464

metagn opened this issue Oct 2, 2020 · 1 comment · Fixed by #15987
Labels
VM see also `const` label

Comments

@metagn
Copy link
Collaborator

metagn commented Oct 2, 2020

Example

# fine:
proc access(s: var seq[char], i: int): var char = s[i]

static:
  var s = @['a', 'b', 'c']
  access(s, 2) = '!'
  discard access(s, 0)

# fails:
proc access(s: var string, i: int): var char = s[i]

static:
  var s = "abc"
  access(s, 2) = '!'
  discard access(s, 0)

Current Output

(14, 9) Error: attempt to access a nil address
if you comment out the previous one:
(15, 17) Error: attempt to access a nil address kind: rkInt

Expected Output

compiles

Additional Information

$ nim -v
Nim Compiler Version 1.3.5
(latest devel)
@mratsim mratsim added the VM see also `const` label label Oct 3, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 16, 2020
…[ind])` (index + index assignment), var char return etc
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 16, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 25, 2020
…[ind])` (index + index assignment), var char return etc
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 25, 2020
@treeform
Copy link
Contributor

treeform commented Dec 2, 2020

Maybe related? #16226

Araq pushed a commit that referenced this issue Dec 3, 2020
…s `addr(mystring[ind])` (index + index assignment) (#15987)

* fix #15939, fix #15464 VM now supports `addr(mystring[ind])` (index + index assignment), var char return etc
* cleanups
* cstring tests
* add test for bug #15464
* improve test coverage
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
nim-lang#16226 VM now supports `addr(mystring[ind])` (index + index assignment) (nim-lang#15987)

* fix nim-lang#15939, fix nim-lang#15464 VM now supports `addr(mystring[ind])` (index + index assignment), var char return etc
* cleanups
* cstring tests
* add test for bug nim-lang#15464
* improve test coverage
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
nim-lang#16226 VM now supports `addr(mystring[ind])` (index + index assignment) (nim-lang#15987)

* fix nim-lang#15939, fix nim-lang#15464 VM now supports `addr(mystring[ind])` (index + index assignment), var char return etc
* cleanups
* cstring tests
* add test for bug nim-lang#15464
* improve test coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VM see also `const` label
Projects
None yet
3 participants