Skip to content

Mutation incorrectly infers integer literals #157

@elichai

Description

@elichai

Minimally reproducible example:

use mutagen::mutate;

#[mutate]
fn hi(mut ret: i64) -> i64 {
    let sh = if ret > 5 {
        0
    } else {
        8
    };
    ret += sh - 1;
    ret
}

fn main() {
    println!("Hello, world! {}", hi(500));
}

Without the macro it compiles fine. with the macro it returns the following:

error[E0277]: cannot add-assign `i32` to `i64`
  --> src/main.rs:11:9
   |
11 |     ret += sh - 1;
   |         ^^ no implementation for `i64 += i32`
   |
   = help: the trait `std::ops::AddAssign<i32>` is not implemented for `i64`

mutagen dep: git+https://github.com/llogiq/mutagen.git#99d9e12bf4e28e3a734b36f216650cec09a54c6c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions