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

cstring.default.len raises a js error instead of returning 0 as in other backends #16674

Closed
timotheecour opened this issue Jan 10, 2021 · 2 comments · Fixed by #16979
Closed

Comments

@timotheecour
Copy link
Member

timotheecour commented Jan 10, 2021

Example

proc main()=
  var a: cstring
  echo a.len
static: main()
main()

Current Output

c:
vm: 0
rt: 0
js:
vm: 0
rt: TypeError: Cannot read property 'length' of null

Expected Output

c:
vm: 0
rt: 0
js:
vm: 0
rt: 0

Additional Information

@metagn
Copy link
Collaborator

metagn commented Jan 11, 2021

a.length => a != null ? a.length : 0 in jsgen with a temp should do it

@ringabout
Copy link
Member

ringabout commented Jan 11, 2021

ditto: low/high(cstring(nil)) in JS backend

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.

3 participants