charon icon indicating copy to clipboard operation
charon copied to clipboard

Bug: poly items show up in names with `--monomorphize`

Open ssyram opened this issue 6 months ago • 2 comments

The following codes produce Not_found error in the main function when calls Charon with --monomorphize. This seems to be something to do with the NameMatcher mechanism.

trait SomeTrait {
    fn some_method(&self);
}

struct Point<T> { x : i32, y : u64, z : T }

impl SomeTrait for Point<i32> {
    fn some_method(&self) {
        assert!(self.x > 0 && self.y < 100 && self.z != 0);
    }
}

fn main() {
    let p = Point { x: 10, y: 50, z: 1 };
    p.some_method();
}

ssyram avatar Jun 10 '25 10:06 ssyram

Thanks for the minimized bug! I can reproduce it, and I understand it: we're keeping the impl around after monomorphization, and it referes to the polymorphic version of Point, which doesn't exist after monomorphization. That's definitely a bug.

Nadrieril avatar Jun 10 '25 12:06 Nadrieril

Thanks for the quick pinpointing! I spent an hour or two tracking this issue but was still not very clear about how this comes.

ssyram avatar Jun 10 '25 15:06 ssyram