andremm / typedlua

An Optional Type System for Lua
565 stars 53 forks source link

enforce count of function parameters? #24

Closed raould closed 9 years ago

raould commented 9 years ago

Please see https://github.com/raould/typedlua/tree/master/QUESTIONS/1 for runnable (linux) example. The gist of it is that I'd like a "missing" argument to be flagged, but it isn't in the case demo'd in the linked code.

andremm commented 9 years ago

You are not getting a type error because you are redeclaring m with type any. You may want to write main.tl as follows:

local m = require "draw"
function loop()
   for i = 1, 3 do
      m.foo( i ) -- now you have a type error,
                 -- because (number, nil*) does not match (any, number, value*),
                 -- which is the input type of m.foo
   end
end
loop()
raould commented 9 years ago

Ok, I will try to comprehend, thanks for the info!