You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[wasm_bindgen] tries to parse the function as a syn::ItemFn which fails on the function's block (specifically on the ( after $js). As mentioned in the linked issue, as best as I can tell, this happens because trailer_expr (in expr.rs) returns if it sees a group which causes Block::parse_within to only see $js rather than the whole expression. Block::parse_within then expects a semicolon after $js (since it's not the last thing in the block) which it doesn't see and so it errors.
As mentioned in the linked issue's thread, removing the token::Group check in trailer_expr seems to fix this problem but I don't know if this will cause other problems; I'm not very familiar with syn's internals.
I noticed #832 altered that exact check; I tested again with 1.0.26 and I still get the same error.
Also, slightly unrelated, but would it be correct for the error here to be "expected semicolon"?
The text was updated successfully, but these errors were encountered:
rrbutani
changed the title
Parsing a syn::ItemFn fails with "unexpected token"
Parsing a syn::ItemFn fails with "unexpected token" on nightlies newer than 2020-05-24
May 26, 2020
Caused by rust-lang/rust#72388; this has more details.
Here's a (kind of, but not really) minified test case:
#[wasm_bindgen]
tries to parse the function as asyn::ItemFn
which fails on the function's block (specifically on the(
after$js
). As mentioned in the linked issue, as best as I can tell, this happens becausetrailer_expr
(inexpr.rs
) returns if it sees a group which causesBlock::parse_within
to only see$js
rather than the whole expression.Block::parse_within
then expects a semicolon after$js
(since it's not the last thing in the block) which it doesn't see and so it errors.As mentioned in the linked issue's thread, removing the
token::Group
check intrailer_expr
seems to fix this problem but I don't know if this will cause other problems; I'm not very familiar withsyn
's internals.I noticed #832 altered that exact check; I tested again with 1.0.26 and I still get the same error.
Also, slightly unrelated, but would it be correct for the error here to be "expected semicolon"?
The text was updated successfully, but these errors were encountered: