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 backend] Interaction between if-expressions and addr leads to undefined #19270

Open
dawkot opened this issue Dec 17, 2021 · 4 comments
Open

Comments

@dawkot
Copy link

dawkot commented Dec 17, 2021

Example

var
  x = @["test"]
  y = if true: x.addr else: x.addr

{.emit: "console.log(`y`)".}

Current Output

undefined
$ nim -v
Nim Compiler Version 1.6.2
@hamidb80
Copy link
Contributor

I don't understand what to expect exactly.

@dawkot
Copy link
Author

dawkot commented Dec 24, 2021

Pointers seem to be supported on JS, if that's what you're asking.

@bung87
Copy link
Collaborator

bung87 commented Nov 9, 2022

you can't simply pass ptr seq[string] into js function, but here's another problem , even echo repr y doesn't work, it prints ref 101 --> @[]

@dawkot
Copy link
Author

dawkot commented Nov 9, 2022

From what I recall if you remove the if expression and simply leave y = x.addr, it did print something other than undefined (I guess the implementation detail of how ptr is handled in JS backend).

I think the issue with repr y you mentioned is a side effect of y being undefined, like my output suggested. So there is something wrong going on with the assignment itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants