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

DerivedDeclarator inconsistency #44

Open
imihajlow opened this issue Dec 21, 2023 · 1 comment · May be fixed by #45
Open

DerivedDeclarator inconsistency #44

imihajlow opened this issue Dec 21, 2023 · 1 comment · May be fixed by #45

Comments

@imihajlow
Copy link

Enum DerivedDeclarator combines pointer, array, and function declarators. However, pointer declarators in C behave differently from array and function declarators. Pointer declarators are considered in right-to-left order, but array declarators go from left to right. For example:

int * const * volatile a[2][4];

This declares a as (array 2 of (array 4 of (volatile pointer to (const pointer to (int))))), but the DerivedDeclarators will be provided in the following order: Pointer(const), Pointer(volatile), Array(2), Array(4).

When using this list of DerivedDeclarators to build C types, special care should be taken to apply pointers in one direction and when they end, apply the rest in reverse direction. It would be more convenient to have RTL declarators and LTR declarators separated in the AST type system.

This is only my wish and suggestion and not a bug report. Please feel free to reject this issue as "won't do" if it goes against the philosophy of your crate.

vickenty added a commit that referenced this issue Dec 21, 2023
@vickenty vickenty linked a pull request Dec 21, 2023 that will close this issue
@vickenty
Copy link
Owner

Yes, I think it makes sense. Perhaps something like #45?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants