teal-language / tl

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

Bidirectional inference did not resolve nested generics #499

Closed hishamhm closed 2 years ago

hishamhm commented 2 years ago

Discussed in https://github.com/teal-language/tl/discussions/498

Originally posted by **lua-rocks** December 29, 2021 This is example from tutorial, but I changed value **3** to **"wtf"** and I expected to get an error, because X in this case is a number and "wtf" is a string. But there are no errors. Why? ```lua local record Tree {Tree} item: X end local t: Tree = { item = 1, { item = 2 }, { item = "wtf", { item = 4 } }, } ``` Also VSCode says that `t[2].item` is `number` 🙈 ![screenshot](https://user-images.githubusercontent.com/82697845/147654510-fafa7526-95ad-4791-9135-f23df5915a9e.png)
hishamhm commented 2 years ago

This is indeed a bug! I'm pushing a quick fix now. Thanks for reporting @lua-rocks!