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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Extend type checking record support for positional arguments #1374

Closed
nathanrpage97 opened this issue Jul 23, 2022 · 0 comments
Labels
enhancement New feature or request feat/type check Related to the type checking feature
Milestone

Comments

@nathanrpage97
Copy link

I've been looking to add more python style function calls where you can mix both have positional arguments and keyword arguments.

It almost works already 馃槃 except type checking is not done for positional arguments in the caller. Inside the function it works well.

---@param args {a: integer, b: integer|nil, test: string}
local function test_no_pos(args)
    -- these are correctly typed
    local a = args.a
    local b = args.b
end

-- everything works correctly
test_no_pos {a = "23", b = "2", test = "string"} -- correctly errors on a,b
test_no_pos({a = "23", b = "2", test = "string"}) -- correctly errors on a,b

---@param args {[1]: integer, [2]: integer|nil, test: string}
local function test_pos(args)
    -- these are also correctly typed
    local a = args[1]
    local b = args[2]
end

test_pos {"23", "2", test = "string"} -- does not error
test_pos({"23", "2", test = "string"}) -- does not error
@sumneko sumneko added enhancement New feature or request feat/type check Related to the type checking feature labels Jul 23, 2022
@sumneko sumneko added this to the 3.6.0 milestone Sep 19, 2022
@sumneko sumneko closed this as completed in 8850130 Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat/type check Related to the type checking feature
Projects
None yet
Development

No branches or pull requests

2 participants