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

fix: use var_{id} as local variable name to avoid the name conflict with tuple struct #266

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

Ggiggle
Copy link
Contributor

@Ggiggle Ggiggle commented Sep 18, 2024

Motivation

Since we will generate the enum type in thrift as newtype in rust, that is a tuple struct, there comes a compile error that let bindings cannot shadow tuple structs when the field name in idl is same as the tuple struct.
For example, the idl below

enum Index {
    A = 0x01,
    B = 0x10,
}

struct Request {
    1: required Index Index,
    2: Index index,
}

service Test {
   void test_enum_var_type_name_conflict (1: Request req);
}

Solution

We will generate a local variable name with the new rule var_{field.id} rather than the rust name of the field to avoid the conflict.

@Ggiggle Ggiggle requested review from a team as code owners September 18, 2024 10:34
PureWhiteWu
PureWhiteWu previously approved these changes Sep 18, 2024
@Ggiggle Ggiggle merged commit daa6ec6 into main Sep 18, 2024
10 checks passed
@Ggiggle Ggiggle deleted the fix/var_shadow_tuple_type branch September 18, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants