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 codegen. assert statement generates syntactically invalid code. #2696

Closed
yglukhov opened this issue May 11, 2015 · 3 comments
Closed

JS codegen. assert statement generates syntactically invalid code. #2696

yglukhov opened this issue May 11, 2015 · 3 comments

Comments

@yglukhov
Copy link
Member

assert(true)

related code in js:

function raiseassert_11879(msg_11881) {
var F={procname:"system.raiseAssert",prev:framePtr,filename:"lib/system.nim",line:0};
framePtr = F;
sysfatal_11884(, msg_11881); // Syntax error here
framePtr = framePtr.prev;
}
@yglukhov
Copy link
Member Author

Git bisect showed the first bad commit: c5db4fc. @def-, could you take a look please?

@def-
Copy link
Member

def- commented May 16, 2015

I changed sysFatal from a template to an inline proc. This seems to trigger a bug in the JS backend with procs that take a typedesc:

type T = object
proc f(t: typedesc, s: string) = discard
f(T, "foobar")

This produces wrong JS code for the proc call:

f_14013(, cstrToNimstr("foobar"));

Somehow the first argument in the AST ends up being something totally wrong. In the C backend it's just removed, but I'm not sure where that happens and why it doesn't happen in the JS backend.

@dom96
Copy link
Contributor

dom96 commented May 19, 2015

Fixed by #2761

@dom96 dom96 closed this as completed May 19, 2015
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

3 participants