Skip to content

Wrong location is reported when getproperty is defined by the user #469

@EdsterG

Description

@EdsterG

When getproperty is overridden by the user, field errors point to the wrong location. Here's a minimal example:

struct Test
    x::Int
end

function Base.getproperty(o::Test, s::Symbol)
    if s === :y
        return getfield(o, :x)
    else
        return getfield(o, s)                  # FieldError for `z` points to this line
    end
end

function test(x::Test)
    x.z                                        # I'd expect the field error to point here
end

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