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

FRB does not parse escaped names correctly #2346

Open
poborin opened this issue Oct 10, 2024 · 1 comment
Open

FRB does not parse escaped names correctly #2346

poborin opened this issue Oct 10, 2024 · 1 comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working

Comments

@poborin
Copy link

poborin commented Oct 10, 2024

Describe the bug

Given the struct contains an escaped name

struct A {
  pub r#type: String
}

When the FRB generates a Dart file it contains r#type filed while it should have a type

Steps to reproduce

in the Rust code use a reserved name such as:

  1. fileds
struct A {
  pub r#type: String
}
  1. function name
fn #for() {}
  1. parameter name
fn test(r#type: String) {}

then run FRB generation

Logs

Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
   ╷
39 │  UserType get r#type;
   │                 ^^^^

----------------------------------

stderr=error: missing parameters for function definition
   --> .../rust/src/frb_generated.rs:464:69
    |
464 | ...   }fn wire__types__model__common__User_auto_accessor_get_r#type_impl(ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUin...
    |                                                               ^
    |
help: add a parameter list
    |
464 |             }fn wire__types__model__common__User_auto_accessor_get_r()#type_impl(ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,rust_vec_len_: i32,data_len_: i32) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse {
    |                                                                     ++

error: expected one of `->`, `<`, `where`, or `{`, found `#`
   --> .../rust/src/frb_generated.rs:464:69

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

@poborin poborin added the bug Something isn't working label Oct 10, 2024
@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Oct 10, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 10, 2024

Looks like a bug and feel free to PR for this! Alternatively I may work on it later. The workaround is to avoid such special names by renaming it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants