Skip to content

bug: parent: punning and piracy #2381

@nsajko

Description

@nsajko

parent is a function defined in Base.

  • AbstractAlgebra reuses the same function, parent, with completely different semantics. This is a bug and is known as type punning.

  • This approach also leads to type piracy, xref issue Type piracy in AbstractAlgebra #1387.

This is quite bad, but the fix should be straightforward, while possibly somewhat breaking for dependents:

  • Introduce a new function with the same name, parent, but owned by AbstractAlgebra, or by one of its submodules.

  • Then dependents may need to do using AbstractAlgebra: parent to disambiguate between Base.parent and AbstractAlgebra.parent.

It might also make sense to introduce a public alias for AbstractAlgebra.parent with a different name, to help dependents with name clashes. For example, AbstractAlgebra.parent_abstractalgebra.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions