In testfile.tl, I have the example from André's thesis. In testfile2.tl, I have code which uses the class which has been defined.
testfile.tl
local Shape = { x = 0.0, y = 0.0 }
const function Shape:new (x:number, y:number):self
local s:self = setmetatable({}, { __index = self })
s.x = x
s.y = y
return s
end
const function Shape:move (dx:number, dy:number):()
self.x = self.x + dx
self.y = self.y + dy
end
return Shape
testfile2.tl
local shape = require("testfile")
local s = shape:new(3,2)
shape:move(20,25)
Running on tlc on testfile2, I get the following errors
./testfile.tl:4:9: type error, self type appearing in a place that is not a first parameter or a return type inside type 'self', replacing with 'any'
testfile2.tl:3:11: type error, attempt to pass '(nil, 3, 2, nil*)' to field of input type '({x:number, y:number, const new:(self, number, number, value*) -> (self, nil*), const move:(self, number, number, value*) -> (nil*)}, number, number, value*)'
testfile2.tl:4:1: type error, attempt to pass '(nil, 20, 25, nil*)' to field of input type '({x:number, y:number, const new:(self, number, number, value*) -> (self, nil*), const move:(self, number, number, value*) -> (nil*)}, number, number, value*)'
The latter two errors are due to env.self being nil when check_invoke is called. Of course, it should be nil in this case, but check_invoke assumes that it isn't. I haven't examined the first error.
This is probably an issue for me to deal with. But just so people know that this exists, I decided to file an issue for it.
In testfile.tl, I have the example from André's thesis. In testfile2.tl, I have code which uses the class which has been defined.
testfile.tl
testfile2.tl
Running on tlc on testfile2, I get the following errors
The latter two errors are due to env.self being nil when check_invoke is called. Of course, it should be nil in this case, but check_invoke assumes that it isn't. I haven't examined the first error.
This is probably an issue for me to deal with. But just so people know that this exists, I decided to file an issue for it.