Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect 'Illegal override' when using multiple return values in combination with inheritance #65

Closed
pouwelsjochem opened this issue Mar 15, 2021 · 0 comments

Comments

@pouwelsjochem
Copy link
Contributor

Environment

name version
IDEA version IC2020.3
Luanalysis version 1.2.2
OS MacOS Big Sur

What are the steps to reproduce this issue?

local function createMyObject()
    local vehicle = {} ---@class Vehicle
    vehicle.mySuperObject = vehicle

    function vehicle:getVehicle()
        return vehicle
    end
    function vehicle:getVehicleAndSomethingElse()
        return vehicle, true
    end

    return vehicle
end

local function createMyObjectSubClass()
    local car = {} ---@class Car : Vehicle

    function car:getVehicle()
        return car
    end
    function car:getVehicleAndSomethingElse() -- Illegal override of "getVehicleAndSomethingElse". Type mismatch. Required: 'fun(): Vehicle, true' Found: 'fun(): Car, true'
        return car, true
    end
    function car:getVehicleAndSomethingElse()
        return car.mySuperObject, true
    end

    return car
end

What happens?

The first override of getVehicleAndSomethingElse gets an error, while the getVehicle override doesn't while they effectively have the same signature except for one returning multiple values.

What were you expecting to happen?

The first override of getVehicleAndSomethingElse to correctly resolve its type inheritance.

Any other comments?

This might be related to #44, but might also be an addition to it. Using something similar to #44's example will also only give the incorrect 'Illegal override' on the getStringAndSomethingElse method.

    function vehicle:getString()
        return string.upper("a")
    end
    function vehicle:getStringAndSomethingElse()
        return string.upper("a"), true
    end
    function car:getString()
        return "A"
    end
    function car:getStringAndSomethingElse()
        return "A", true
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant