teal-language / tl

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

Teal does not seem to support `__index` #541

Closed makspll closed 2 years ago

makspll commented 2 years ago

Having a custom __index metamethod:

 metamethod __index: function(LuaVec<T>,integer):(ReflectedValue)

does not allow me to index my type with integers,

is this intended? It's very much annoying to work around

hishamhm commented 2 years ago

is this intended?

No, it's just not implemented! Patches are definitely welcome!

hishamhm commented 2 years ago

I just committed some initial support! For now, only functions as __index are handled and it only resolves __index when using t[x] (not with t.k or t:k). But it should address these "vector-like" use-cases already.

makspll commented 2 years ago

that's perfect, thank you!