Skip to content

Fix sizeof precedence#168

Merged
amaanq merged 3 commits intotree-sitter:masterfrom
philipturnbull:sizeof-precedence
Oct 4, 2023
Merged

Fix sizeof precedence#168
amaanq merged 3 commits intotree-sitter:masterfrom
philipturnbull:sizeof-precedence

Conversation

@philipturnbull
Copy link
Contributor

Increase the precedence of sizeof. Previously, an expression like:

len = sizeof(int) + 1;

would be parsed as:

len = sizeof ((int) + 1);

i.e the size of +1 cast to an int.


Also:

  • I also added tests to offsetof(...) to check that it behaves correctly.
  • Wrong precedences for sizeof and conditional operator #51 mentions problems with the precedence of the ternary operator, but that appears to have been fixed since the issue was opened. I added a couple of tests to prevent regressions in the future.

Fixes #51

@amaanq
Copy link
Member

amaanq commented Oct 4, 2023

Can you regenerate w/ the Rust cli crate on master?

@aryx aryx requested a review from amaanq October 4, 2023 21:02
@amaanq amaanq merged commit f1075f2 into tree-sitter:master Oct 4, 2023
@philipturnbull philipturnbull deleted the sizeof-precedence branch October 4, 2023 23:40
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 this pull request may close these issues.

Wrong precedences for sizeof and conditional operator

2 participants