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

Return statement does not get type checked #639

Closed
nikitug opened this issue Mar 12, 2023 · 3 comments
Closed

Return statement does not get type checked #639

nikitug opened this issue Mar 12, 2023 · 3 comments

Comments

@nikitug
Copy link

nikitug commented Mar 12, 2023

I've noticed that the code below does not produce unknown field y error, but I'd expect it to do so.

local type X = record
  x: number
end

local function test(): X
  return { y = 1 }
end

test()

P.S. Thank you for the great Lua tools! :)

@hishamhm
Copy link
Member

@nikitug Are you sure you are running the latest version? It does produce the error in 0.15.1, and also testing online with the master branch:

https://teal-playground.netlify.app/?c=bG9jYWwgdHlwZSBYID0gcmVjb3JkCiAgeDogbnVtYmVyCmVuZAoKbG9jYWwgZnVuY3Rpb24gdGVzdCgpOiBYCiAgcmV0dXJuIHsgeSA9IDEgfQplbmQKCnRlc3QoKQ%3D%3D

(Looks like there's a quirk in the playground — you need to edit something (e.g. prest Enter) so that the compiler refreshes, and then the "y" will appear underlined in red and when you hover it, it does say unknown field y)

@hishamhm
Copy link
Member

Closing this issue for now (I've opened one in the playground for the refresh issue) — feel free to reopen if you find a different test case where this problem persists!

@hishamhm hishamhm closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2023
@nikitug
Copy link
Author

nikitug commented Mar 13, 2023

@hishamhm Thank you for your quick reply! You are right – I have not noticed I've been using a global executable from homebrew (not sure how I even have it though), not the one from my home dir with the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants