pigpigyyy / Yuescript

A Moonscript dialect compiles to Lua.

Home Page:http://yuescript.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Classes dont inherits metamethods properly

kithf opened this issue · comments

commented

Seems that when the child extend the parent, it does some strange things?
Tested on https://yuescript.org/try/ and LuaJIT 2.1.0-beta3 results are the same.
image

Code to reproduce:

class A
  <tostring>: => return "321"
  
class B extends A

a, b = A!, B!

print tostring a -- 312
print tostring b -- table: ...
print getmetatable(b).__tostring, -- function: ...
      getmetatable(b).__tostring(b) -- 312

It's the Lua rule that only does raw-get to access the metamethods. I updated the generated codes to insert super metamethods into derived class object.