Skip to content

varargs in nullish coalescing expression breaks #1165

@tomblind

Description

@tomblind
function foo(...args: unknown[]) {}

function bar(...args: unknown[]) {
    const x: boolean = false;
    const y = x ?? foo(...args);
}
function foo(self, ...)
end
function bar(self, ...)
    local x = false
    local y = (function(____lhs)
        if ____lhs == nil then
            return foo(nil, ...) -- error: cannot use '...' outside a vararg function
        else
            return ____lhs
        end
    end)(x)
end

Playground

This is caused by transformNullishCoalescingExpression creating its own IIFE instead of using the utility functions. It may be a good idea to wait to fix this after #1116 is finished.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions