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

Adjust the code generated for enum types to avoid conflicting with names not reserved by the Flatbuffers IDL #8285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

insertjokehere
Copy link
Contributor

Fixes #8052

The Flatbuffers IDL allows for enums to have values called value, values, minValue or maxValue, but if these names are used for values in an enum, the generated Dart code won't compile.

This modifies the Dart generator to use $value, $values, $minValue and $maxValue instead, so that valid Flatbuffer schemas can be used with Dart

@github-actions github-actions bot added c++ codegen Involving generating code from schema dart labels Apr 19, 2024
…mes not reserved by the Flatbuffers IDL

Fixes google#8052

The Flatbuffers IDL allows for enums to have values called "value", "values", "minValue" or "maxValue", but if these names are used for values in an enum, the generated Dart code won't compile.

This modifies the Dart generator to use "$value", "$values", "$minValue" and "$maxValue" instead, so that valid Flatbuffer schemas can be used wth Dart
Copy link
Contributor

@vaind vaind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

This is quite a breaking change - it would break anyone accessing these properties. Instead, I'd suggest changing the field name in case it conflicts, which would not break anyone because they couldn't have used that name anyway. That is what we do for conflicts with reserved keywords too (see uses of namer_).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ codegen Involving generating code from schema dart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dart, master] Enum named "value" causes variable name conflict
2 participants