titan-lang / titan

The Titan programming language
http://titan-lang.org
MIT License
406 stars 13 forks source link

fix some regressions with option types #255

Closed mascarenhas closed 6 years ago

mascarenhas commented 6 years ago

Option types introduced some regressions, this PR fixes them and adds tests for those cases.

First regression was indexing an array of arrays, the type checker was not coercing the option in the e1 part of e1[e2] to its non-option version, so code like x[...][...] was failing because x[...] did not have an array type.

Second regression was comparing two option types, which should be like comparing two values. Code like a[1] == b[1] that used to work now was having generating wrong C code because it was trying to compare two TValues (the underlying C type of Lua slots and Titan option types) directly using ==.