Clue
Clue copied to clipboard
Check for errors
At the current state, the compiler doesn't check if a function called in a file from another file is either local or global thus making errors go through the Lua version. Example: main.clue
local test = import("test")
local fn print_var(var) {
print("Info " .. var)
}
print_var("Hello")
print_var(double(2))
print_var(multiply(2, 2))
test.clue
local fn multiply(a, b) {
return a * b
}
global fn double(a) {
return multiply(a, 2)
}
lua main.lua
Info Hello
Info 4
lua: main.lua:40: attempt to call a nil value (global 'multiply')
stack traceback:
main.lua:40: in local 'cached'
main.lua:11: in local 'import'
main.lua:44: in main chunk
[C]: in ?
that is intended? if a function is local it cannot be accessed from other files
yes, but Clue didn't report it during compilation, that's my point
Clue does not keep track of any variable created, it lets Lua handle that This feature will very probably be added alongside types in Clue 3.0
Edit: 4.0 now...
in 3.0 it is possible to implement this when using the mlua feature
This is why this is for 4.0