Skip to content

Default parameters not initialized in stand-alone functions #216

@tomblind

Description

@tomblind

Default parameters work in class methods and arrow functions, but not normal stand-alone functions:

class Foo {
    public method(s = "foo") {}
    public static staticMethod(s = "foo") {}
}

let baz = (s = "baz") => {};

function bar(s = "bar") {}
Foo = Foo or {}
Foo.__index = Foo
function Foo.new(construct, ...)
    local instance = setmetatable({}, Foo)
    if construct and Foo.constructor then Foo.constructor(instance, ...) end
    return instance
end
function Foo.constructor(self)
end
function Foo.method(self,s)
    if s==nil then s="foo" end
end
function Foo.staticMethod(self,s)
    if s==nil then s="foo" end
end
local baz = function(s)
    if s==nil then s="baz" end
end
;
function bar(s) --s is not initialized here
end

Metadata

Metadata

Assignees

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