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

Confusing errors with varargs #244

Open
jrfondren opened this issue Dec 2, 2023 · 0 comments
Open

Confusing errors with varargs #244

jrfondren opened this issue Dec 2, 2023 · 0 comments
Labels

Comments

@jrfondren
Copy link

Bug description

... seems to be a special name in two ways that aren't mentioned by the Overview: it's not otherwise a valid identifier, and a : varargs parameter not given that name is treated as : integer.

Code example

Type error in Nelua:

local function f(items: varargs)
  print(#items) -- error: in unary operation `len`: invalid operation for type 'int64'
end

f(1, 2, 3)

Codegen error:

local function f(items: varargs) -- void va1_f_1(int64_t items)
end

f(1, 2, 3) -- error: too many arguments to function ‘va1_f_1’

Workaround

There's no problem if you write code that uses ...: varargs like in the Overview.

More ... development also seems to be waiting on the any type, based on tests like

it("any type", function()
...
  expect.run_error_c([[
    local function f(...) return ... end
  ]], "not supported yet")

Environment

x86_64 linux
Nelua 0.2.0-dev
Build number: 1610
Git date: 2023-11-19 16:54:45 -0300
Git hash: e82695a
Semantic version: 0.2.0-dev.1610+e82695ab
Copyright (C) 2019-2023 Eduardo Bart (https://nelua.io/)

@jrfondren jrfondren added the bug label Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant