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

cyan attempts to compile lua files as if they were teal files. #43

Open
vlaaad opened this issue Jul 15, 2024 · 2 comments
Open

cyan attempts to compile lua files as if they were teal files. #43

vlaaad opened this issue Jul 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vlaaad
Copy link

vlaaad commented Jul 15, 2024

See repro: cyan-lua-compilation-repro.zip

When I have a following file structure:
Screenshot 2024-07-15 at 15 29 51
And tlconfg.lua set to:

return {
    build_dir = "build",
    include_dir = {"src"},
    source_dir = "src"
}

Then cyan build fails:

$ cyan build
     Error 2 type errors in src/test.lua
       ... src/test.lua 3:7
       ...    3 | local a
       ...      |       ^
       ...      | variable 'a' has no type or initial value
       ... 
       ... src/test.lua 4:7
       ...    4 | local b
       ...      |       ^
       ...      | variable 'b' has no type or initial value
      Info Type checked src/main.tl

It looks like cyan tries to typecheck a lua file as if it was a teal file (even though there is a corresponding .d.tl file!).

@euclidianAce
Copy link
Member

Cyan doesn't currently handle this use case too well. An awkward solution would be to move the lua file into the build directory and use the dont_prune config.

return {
   build_dir = "build",
   include_dir = {"src"},
   source_dir = "src",
   dont_prune = { "build/test.lua" },
}

Or keep your lua sources in a different directory and use a build script to copy them over.

But this use case seems reasonable enough to be supported by default.

@hishamhm
Copy link
Member

hishamhm commented Sep 2, 2024

@euclidianAce I think I'm hitting the same issue when trying to use Cyan with the teal branch of LuaRocks.

Right now I have two kinds of Lua files under src, and I want to ignore both:

  • generated .lua files from the .tl files (I'm still keeping them under src/ to keep the build scripts compatible). I managed to get Cyan to ignore this by adding exclude = { "**/*.lua" } in my tlconfig.lua file
  • vendored Lua modules such as src/luarocks/vendor/argparse.lua, for which I have a src/luarocks/vendor/argparse.d.tl file. Looks like Cyan is still checking the .lua file (and thus outputting lots of errors) because these are referenced by other files as dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants