Closed PinocchioStrings closed 2 years ago
I'm unable to reproduce this on either the latest master
or the latest release — I created the file somefile.d.tl
with the above 5 lines, but tl check somefile.d.tl
passes, it only produces warnings about the unused local variables, as expected.
I did some further testing and it turns out that the problem only occurs when the same somefile is specified as global_env_def (using tlconfig.lua or command line option).
I guess that makes sense, tl would probably be processing the same file twice as though they were a single file? Alas the problem is that it makes "tl check" (and the teal vscode plugin) worse than useless for the global_env_def file.
If this is the case, then the solution would be to prevent tl from using the global_env_def file when it is the same as the file currently being checked.
(Quite aside from that, I already disabled the teal plugin because it tendsto crash and generate error popups during normal use).
@PinocchioStrings Could you test this quick hack and see if it solves the issue for you?
diff --git a/tl b/tl
index 42a7832..d291884 100755
--- a/tl
+++ b/tl
@@ -135,7 +135,7 @@ local function setup_env(tlconfig, filename)
local gen_target = tlconfig["gen_target"]
tlconfig._init_env_modules = tlconfig._init_env_modules or {}
- if tlconfig.global_env_def then
+ if tlconfig.global_env_def and tlconfig.global_env_def ~= filename then
table.insert(tlconfig._init_env_modules, 1, tlconfig.global_env_def)
end
This might not be smart enough — e.g. for detecting absolute versus relative pathnames — but it might prove sufficient. @euclidianAce: do you think Cyan suffers from a similar issue?
I'm on Windows with the precompiled executable.
Alternatively you could allow redeclarations as long as they are the same.
I'm thinking you may want to do that anyway. In which case that would also solve this.
Facing same bug on linux
Ah, that makes sense! I missed the misleading error message.