teal-language / tl

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

__call metamethod is "not a function" when declared with a named function type #605

Closed shviller closed 1 year ago

shviller commented 1 year ago

This typechecks as expected:

local record Callable
  metamethod __call: function(self: Callable): boolean
end

local function f(): boolean
  local callable = {} as Callable
  return callable()
end

f()

However, this errors with "not a function: Call_Type":

local record Callable
  type Call_Type = function(self: Callable): boolean
  metamethod __call: Call_Type
end

local function f(): boolean
  local callable = {} as Callable
  return callable()
end

f()

(checked using code currently in master)

hishamhm commented 1 year ago

Thanks for the test cases! Fixed!