The Wayback Machine - https://web.archive.org/web/20201128130424/https://github.com/andremm/typedlua/issues/76
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self type broken #76

Closed
kevinclancy opened this issue May 15, 2016 · 0 comments
Closed

self type broken #76

kevinclancy opened this issue May 15, 2016 · 0 comments

Comments

@kevinclancy
Copy link

@kevinclancy kevinclancy commented May 15, 2016

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.

mascarenhas added a commit that referenced this issue May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.