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

Unable to compile Teal code with definitions for regular Lua modules #4

Open
Lerg opened this issue Jul 7, 2024 · 3 comments
Open

Comments

@Lerg
Copy link

Lerg commented Jul 7, 2024

Teal supports requiring regular Lua file given that a special definition file is created.

For instance test.lua

local M = {}

local a
local b

a = 5
b = a + 2

M.c = b

return M

Definition file test.d.tl

local record test
    c: number
end

return test

When invoking command line tl it doesn't give any errors:

TealBug % tl check main/main.tl
========================================
Type checked main/main.tl
0 errors detected -- you can use:

   tl run main/main.tl

       to run main/main.tl as a program

   tl gen main/main.tl

       to generate main.lua

tl gen also works.

But when trying to build with Defold an error appears

/tlconfig.lua
	Line 3: variable 'a' has no type or initial value
	Line 4: variable 'b' has no type or initial value
Screenshot 2024-07-07 at 22 46 58

Somehow the original Lua module (test.lua) gets treated as a Teal source which results in compilation errors

Test project:
TealBug.zip

@vlaaad
Copy link
Collaborator

vlaaad commented Jul 8, 2024

Does your tlconfig.lua have this code?

return {
     gen_target = "5.1",
     gen_compat = "off",
     include = {"**/*.tl"}
}

@Lerg
Copy link
Author

Lerg commented Jul 8, 2024

Does your tlconfig.lua have this code?

@vlaaad Yes

@vlaaad
Copy link
Collaborator

vlaaad commented Jul 15, 2024

Hmm, I can reproduce the issue. Reported to cyan: teal-language/cyan#43 The issue can also be solved with defold/defold#8928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants