Skip to content

Generic's type is always assumed to be a table even when it isn't #1053

@Frityet

Description

@Frityet
local record Box<T> where (function(k: any): boolean return k is T end)(self.children[1])
    children: {any}
end

local a: Box<integer> | Box<string> = (function(): Box<integer> return { children = { 1 } } end)()

if not a is Box<integer> then error "pluh" end

errors with pluh, even though it should be valid, this is because the code generates to

local a = (function() return { children = { 1, "two", "thrwee" } } end)(); if not (function(k) return type(k) == "table"





end)(a.children[1]) then error("pluh") end

whilst it should be math.type(k) == "integer"

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