Skip to content

Conversation

@eagr
Copy link
Contributor

@eagr eagr commented Dec 29, 2024

part of #9783

@eagr eagr requested review from a team as code owners December 29, 2024 09:55
@eagr eagr requested review from cfallin and fitzgen and removed request for a team December 29, 2024 09:55
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:meta Everything related to the meta-language. pulley Issues related to the Pulley interpreter labels Dec 29, 2024
@github-actions
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:meta", "pulley"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

const MIN: i32 = i16::MIN as i32;
const MAX: i32 = i16::MAX as i32;
for (a, b) in a.iter_mut().zip(b) {
let r = i32::from(*a) * i32::from(b) + (1 << 14) >> 15;
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit surprised by the lack of parentheses around this, I would have expected:

let r = (i32::from(*a) * i32::from(b) + (1 << 14)) >> 15;

as otherwise the final term (1 << 14) >> 15 looks like it currently evaluates to 0.

Tests, however, are passing with this PR which means that either the precedence rules of parsing in Rust are different from what I expect or that the tests don't actually cover the case which needs the parentheses to be right here. Would you be up for debugging this a bit to figure out what's going on test-wise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You must have always been in the good habit of applying parentheses when in doubt so you don't have to remember the precedence rules :)

I think this is equivalent to what you expect. Let me just add those parentheses and you'd see the same result. The code reads better that way anyways. And btw the tests are looking good to me.

Copy link
Member

Choose a reason for hiding this comment

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

Oh nice, thanks for checking!

@alexcrichton alexcrichton added this pull request to the merge queue Dec 29, 2024
Merged via the queue into bytecodealliance:main with commit 2d1c0ab Dec 29, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator pulley Issues related to the Pulley interpreter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants