@@ -661,8 +661,23 @@ analyze(
661661 }
662662 t.foo["test"] = true
663663]] ,
664- " is not a subset of nil"
664+ " true is not a subset of nil"
665665)
666+ analyze (
667+ [[
668+ local t = {} as {
669+ foo = {foo = string}
670+ }
671+ t.bar = 1
672+ ]] ,
673+ " has no key \" bar\" "
674+ )
675+ analyze ([[
676+ local t = {} as {
677+ foo = {foo = string, [string] = string | nil}
678+ }
679+ t.foo["test"] = "bar"
680+ ]] )
666681analyze [[
667682 local t = {} as {[1 .. inf] = number}
668683 attest.equal(#t, _ as 1 .. inf)
@@ -1071,4 +1086,32 @@ for i, v in ipairs(x) do
10711086 x[i] = nil
10721087end
10731088attest.equal(x, _ as {foo = 1, bar = 2, faz = 3})
1074- ]]
1089+ ]]
1090+
1091+ test (" repro number is not a subset of nil" , function ()
1092+ analyze ([=[
1093+ local type TProfile = {
1094+ _strings = {[number] = string | nil},
1095+ _string_lookup = {[string] = number | nil},
1096+ _string_count = number,
1097+ _strings_flushed = number,
1098+ }
1099+
1100+ local function intern(self, s)
1101+ self = self--[[# as TProfile]]
1102+ s = s--[[# as string | nil]]
1103+ if not s then return -1 end
1104+
1105+ local sl = self._string_lookup
1106+ local idx = sl[s]
1107+
1108+ if idx then return idx end
1109+
1110+ idx = self._string_count
1111+ self._string_count = self._string_count + 1
1112+ self._strings[idx] = s
1113+ sl[s] = idx
1114+ return idx
1115+ end
1116+ ]=] )
1117+ end )
0 commit comments