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

Adding a semi-colon causes issues on the transform #8

Closed
gregtatum opened this issue Nov 27, 2017 · 2 comments
Closed

Adding a semi-colon causes issues on the transform #8

gregtatum opened this issue Nov 27, 2017 · 2 comments
Labels

Comments

@gregtatum
Copy link

I'd like to do something like this, but the semi-colon added at the beginning of the statement causes a syntax error:

;(async () => {
  const { addOne } = await instantiateWasm(rust`
    #[no_mangle]
    pub fn addOne(x: i32) -> i32 {
      x + 1
    }
  `)
})()
@yoshuawuyts
Copy link
Member

@gregtatum Uh oh that's no good. It's probably this code that's probably causing it: https://github.com/browserify/rustify/blob/master/lib/transform.js#L82-L85

What's the resulting (incorrect) code look like? We should probably add the statement type to the whitelist so it doesn't generate it. The node type can be found by passing the ^ code into https://astexplorer.net/.

@goto-bus-stop
Copy link
Member

I think we may not need the semicolon code here at all. sheetify needs it because the replacement code starts with an open-paren which may trip up ASI, but rustify's starts with new which doesn't have that issue.

goto-bus-stop added a commit that referenced this issue Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants