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

project generation fails with "Error: attempt to index a function value" #1795

Closed
somyungoh opened this issue Jan 11, 2022 · 2 comments · Fixed by #1796
Closed

project generation fails with "Error: attempt to index a function value" #1795

somyungoh opened this issue Jan 11, 2022 · 2 comments · Fixed by #1796
Labels

Comments

@somyungoh
Copy link
Contributor

somyungoh commented Jan 11, 2022

What seems to be the problem?
Premake5 raises an error during any project generation:

Building configurations...
Error: attempt to index a function value
stack traceback:
        [string "src/base/api.lua"]:309: in field 'checkValue'
        [string "src/base/oven.lua"]:255: in local 'base'
        (...tail calls...)
        [string "src/base/oven.lua"]:197: in field 'bakeConfigs'
        [string "src/base/oven.lua"]:44: in field 'bake'
        [string "src/base/container.lua"]:61: in field 'bake'
        [string "src/base/container.lua"]:69: in field 'bakeChildren'
        [string "src/base/global.lua"]:8: in field 'bake'
        [string "src/base/container.lua"]:61: in field 'bake'
        [string "src/base/oven.lua"]:12: in field 'bake'
        [string "src/_premake_main.lua"]:163: in field '?'
        [string "src/base/_foundation.lua"]:62: in function 'premake.callArray'
        [string "src/_premake_main.lua"]:225: in function '_premake_main'

What version of Premake are you using?
premake 5.0-alpha16

Anything else we should know?
Digging into the code, I've noticed that in the file api.lua, a function type is passed to ipairs() which is not allowed:

-- api.lua, line 661

if not canonical then
    for _, allow in ipairs(field.allowed)       <---------- here
        do
            if type(allow) == "function" then
            ...

I did a small patch myself, I'll create a PR that should fix this.

@nickclark2016
Copy link
Member

Have you verified that this is an issue with the beta-1 build? Also, what in your build script is causing the issue? I want to isolate the cause before we dive headfirst into fixing it.

@Jarod42
Copy link
Contributor

Jarod42 commented Jan 13, 2022

From the above code, field.allowed might be a function (and from assignment, it happens for toolset and uuid).

As I understand, invalid values for those api would trigger internal lua error instead of displaying the friendly Premake error message.

samsinsane added a commit that referenced this issue Apr 8, 2022
Fix #1795: project generation fails with "Error: attempt to index a function value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants