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

dart_code does not accept code blocks #1968

Closed
uditrugman opened this issue May 24, 2024 · 4 comments · Fixed by #1986 or #2000
Closed

dart_code does not accept code blocks #1968

uditrugman opened this issue May 24, 2024 · 4 comments · Fixed by #1986 or #2000
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@uditrugman
Copy link

Describe the bug

codegen fails on the below:

#[frb(dart_code = "
    int testDartCode() {
        return 3;
    }
"
)]

this is the error:

Error: cannot parse string into token stream

Steps to reproduce

Hint: A simple way to reproduce is to clone and modify the https://github.com/fzyzcjy/flutter_rust_bridge/tree/master/frb_example/dart_minimal example package according to your needs.

  1. ...
  2. ...
  3. ...

Logs

no logs needed. this is just a bug in the parser.
very easy to reproduce. just paste the above code in a rust project and it will fail to gen dart code

Expected behavior

No response

Generated binding code

No response

OS

No response

Version of flutter_rust_bridge_codegen

No response

Flutter info

No response

Version of clang++

No response

Additional context

No response

@uditrugman uditrugman added the bug Something isn't working label May 24, 2024
@fzyzcjy fzyzcjy added the good first issue Good for newcomers label May 24, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented May 24, 2024

Good observation and feel free to PR for it! Alternative I will work on it later.

Btw, try to run with RUST_LOG=debug and paste the stack trace, and I guess this will be fairly easy to fix (thus good-first-issue).

@fzyzcjy
Copy link
Owner

fzyzcjy commented May 29, 2024

(Reopen since that one is accidentally merged)

@fzyzcjy
Copy link
Owner

fzyzcjy commented May 29, 2024

Current workaround before dtolnay/cargo-expand#227 is solved: Try to avoid having a single line with exact content }, which confuses cargo-expand output parser.

Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.