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

parser: fix operator precedence #2096

Merged
merged 1 commit into from
Dec 27, 2021
Merged

parser: fix operator precedence #2096

merged 1 commit into from
Dec 27, 2021

Conversation

fbs
Copy link
Contributor

@fbs fbs commented Dec 21, 2021

1 + 2 *3 is currently evaluated as (1+2)*3 while it should be 1 + (2*3). This is because the additive and multiplicative operators we're
mixed in the same rule.

Tests are only implemented in runtime right now as doing this in the
parser is a bit tedious to write and it doesn't actually guaranteed the
correct output.

Fixes #2095

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@fbs
Copy link
Contributor Author

fbs commented Dec 21, 2021

<.< another build issue with libbpf. I guess we can get this in regardless, as the regular build passes

`1 + 2 *3` is currently evaluated as `(1+2)*3` while it should be `1 +
(2*3)`. This is because the additive and multiplicative operators we're
mixed in the same rule.

Tests are only implemented in runtime right now as doing this in the
parser is a bit tedious to write and it doesn't actually guaranteed the
correct output.

Fixes bpftrace#2095
@fbs
Copy link
Contributor Author

fbs commented Dec 21, 2021

#2097 is the backport for a v0.14.1 release

@fbs
Copy link
Contributor Author

fbs commented Dec 21, 2021

imo we should also backport to 0.13.1, thoughts @danobi @viktormalik?

Copy link
Member

@danobi danobi left a comment

Choose a reason for hiding this comment

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

Maybe add a test that uses all the operators? eg 1 + 2 - 3 << 4 >> 5 or something

@fbs fbs merged commit d3ca161 into bpftrace:master Dec 27, 2021
@fbs
Copy link
Contributor Author

fbs commented Dec 27, 2021

agreed lets add those later

@fbs fbs deleted the 2095 branch December 27, 2021 13:50
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.

None yet

2 participants