Skip to content

Saturn magnitude is still buggy in some cases #76

@alex-vasenin

Description

@alex-vasenin

Saturn magnitude is still buggy in some cases:

    let jd = JulianDay(year: 2018, month: 1, day: 1) // Could be any date
    let jupiter = Jupiter(julianDay: jd)
    let saturn = Saturn(julianDay: jd)
    let uranus = Uranus(julianDay: jd)
    let neptune = Neptune(julianDay: jd)
    let gasGiants = [jupiter, saturn, uranus, neptune]
    print(saturn.magnitude.value) // Prints 0.479, as expected
    print(gasGiants[1].magnitude.value) // Prints nan !!!

This is one of the very few cases where Swift language itself falls short. Saturn's object is both Planet and Saturn. Planet has it's own magnitude as default implementation of IlluminatedFraction protocol. Saturn has it's own magnitude as computed property. Due to static dispatch Swift calls wrong implementation for magnitude in some cases. More info in SR-103.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions