Skip to content

#[pyo3(get)] and #[getter] on same field silently collide #6000

@davidhewitt

Description

@davidhewitt

The following code compiles without issue. I would expect we should either fail to compile or report an error when initializing the type object. Compile error probably leads to better UX, as long as the compiler error is meaningful enough.

#[pyclass]
pub struct Object {
    #[pyo3(get)]
    x: u32,
}

#[pymethods]
impl Object {
    #[getter]
    fn x(&self) -> u32 {
        self.x
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions