defold / defold/extension-teal

Unable to compile Teal code with definitions for regular Lua modules

Open
#4 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Lua
Stars
55
Forks
4
PR merge metrics
No merged PRs in 30d

Description

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

For instance test.lua
```language-lua
local M = {}

local a
local b

a = 5
b = a + 2

M.c = b

return M
```

Definition file test.d.tl
```language-lua
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](https://github.com/user-attachments/files/16120738/TealBug.zip)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the attached TealBug.zip project and compare `tl check`/`tl gen` with the Defold build that reports errors in `tlconfig.lua`. Trace why `test.lua` is treated as Teal source despite `test.d.tl`, then verify that regular Lua modules with definition files build successfully without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.