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

js: ref object assignment silently gives wrong results #16003

Open
timotheecour opened this issue Nov 16, 2020 · 1 comment
Open

js: ref object assignment silently gives wrong results #16003

timotheecour opened this issue Nov 16, 2020 · 1 comment

Comments

@timotheecour
Copy link
Member

timotheecour commented Nov 16, 2020

js: ref object assignment incorrect (related to #14339 which was fixed in #16002, but for js backend)

Example

block:
  type
    Node = ref object
      val: int
  proc bar(c: Node): var int =
    var n = c
    n.val
  var a = Node(val: 3)
  a.bar() = 5
  doAssert a.val == 5 # fails, got 3

Current Output

fails

Expected Output

works

Additional Information

@timotheecour timotheecour changed the title js: ref object assignment incorrect js: ref object assignment silently gives wrong results Nov 16, 2020
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 16, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 16, 2020
@metagn
Copy link
Collaborator

metagn commented Nov 17, 2020

Generated code (mangle numbers removed):

function bar(c) {
  var result = null;
  var result_Idx = 0;

    var n = c;
    result_Idx = [, n.val];
    result = n.val;
    result[result_Idx] = n.val;

  return [result, result_Idx];

}

timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 25, 2020
Araq pushed a commit that referenced this issue Nov 25, 2020
* fix #14339: fixes limited VM support for addr

* strengthen test

* reference bug #16003

* also fixes #13511

* also fixes #14420
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
…support for addr (nim-lang#16002)

* fix nim-lang#14339: fixes limited VM support for addr

* strengthen test

* reference bug nim-lang#16003

* also fixes nim-lang#13511

* also fixes nim-lang#14420
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
…support for addr (nim-lang#16002)

* fix nim-lang#14339: fixes limited VM support for addr

* strengthen test

* reference bug nim-lang#16003

* also fixes nim-lang#13511

* also fixes nim-lang#14420
bung87 added a commit to bung87/Nim that referenced this issue Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants