False warning when including a file with functions
deltamolfar opened this issue · 2 comments
Describe the bug
If you have a function inside of lib file, and then include it in other E2 with @strict - you will get a warning in editor, that 'included file have n warnings', where n == amount of functions inside of included file. But you may have no warnings at all in the included file itself even with strict mode.
To Reproduce
Steps to reproduce the behavior:
- Create a lib file with at least one function.
- Create general E2 with strict mode
- Include lib file into strict mode E2
- Press validate button on bottom of editor
Expected behavior
No warnings lol
Iirc, right before Vurv left - he told that this might originate from strict-mode nested function warnings, as the contents of included file counts as nested code.
Pretty easy fix. IIRC problem is include variables are stored in scope [1]
rather than global scope [0]
in the table.
Well, assuming having includes in the global scope isn't a problem.. then you'll just have to make that warning check nth_scope + 1
if it's in an included file, which that info should exist.
Edit: I already did this for events, wtf
self:AssertW(self.scope:IsGlobalScope() or (self.include and self.scope:Depth() == 1), "Events cannot be nested inside of statements, they are compile time constructs. This will become a hard error in the future!", trace)
- if self.strict and not self.scope:IsGlobalScope() then
+ if self.strict and not (self.scope:IsGlobalScope() or (self.include and self.scope:Depth() == 1)) then