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

truncate!(int!(256)) fails to simplify in Rust #5856

Open
ajewellamz opened this issue Oct 24, 2024 · 0 comments
Open

truncate!(int!(256)) fails to simplify in Rust #5856

ajewellamz opened this issue Oct 24, 2024 · 0 comments
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@ajewellamz
Copy link
Collaborator

Dafny version

4.8.1

Code to produce this issue

function method UInt16ToSeq(x: uint16): (ret: seq<uint8>)
  {
    var b0 := (x / 0x100) as uint8;
    var b1 := (x % 0x100) as uint8;
    [b0, b1]
  }

Command to run and resulting output

dafny test -t rs --function-syntax 3

What happened?

Resulting Rust code is
pub fn UInt16ToSeq(x: u16) -> Sequence {
let mut b0: u8 = (x / truncate!(int!(256), u16)) as u8;
let mut b1: u8 = (x % truncate!(int!(256), u16)) as u8;
seq![b0, b1]
}
when it ought to be
pub fn UInt16ToSeq(x: u16) -> Sequence {
let mut b0: u8 = (x / 256) as u8;
let mut b1: u8 = (x % 256) as u8;
seq![b0, b1]
}

What type of operating system are you experiencing the problem on?

Mac

@ajewellamz ajewellamz added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
Projects
None yet
Development

No branches or pull requests

1 participant