teal-language / tl

The compiler for Teal, a typed dialect of Lua
MIT License
2.1k stars 108 forks source link

Type checking error when using include_dir on windows #580

Open LaylBongers opened 1 year ago

LaylBongers commented 1 year ago

The same type will be seen as mismatching, because of a different path, even though the path refers to the same file.

PS C:\Users\Layl\Desktop\mpgb> tl build
========================================
1 error:
src\main.tl:33:30: argument 1: cc.Redirect (defined in src\cc.d.tl:6) is not a cc.Redirect (defined in .\src/cc.d.tl:6)

tlconfig.lua

return {
    source_dir = "src",
    include_dir = { "src" },
    build_dir = "dist",
    global_env_def = "src/cc",
    gen_target = "5.1",
}
hishamhm commented 1 year ago

@LaylBongers Thanks for the report!

I think one solution for this would be to move the normalize function from the tl script into the tl.tl module, and then use it in the search_for function.

It shouldn't be hard, but I'd really prefer getting a PR from a Windows user implementing this instead of trying it blindly myself on Linux. Test files spec/source_dir_spec.lua and spec/global_env_def_spec.lua should also have some examples on how to write tests for exercising this problem and the solution.