9. 🌴
--# open lua51
--v function(id: int) —> {id = int, name = string, meta = Meta?}
local function build_packet(id)
local p = {}
p.id = id
p.name = to_name(id)
p.aliases = {} --: vector<string>
if has_meta then
local meta = get_meta_from_json(id)
--# assume meta: Meta
p.meta = meta
end
return p
end ( )
45. • 1 . …
--8<-- assume-table
local f = function() end
--# assume f: table
local p = f.index --@< Error: Cannot index `table` without further type information;
specify more detailed type, or use `--# assume` as a last resort
--! error
--8<-- conjunctive-lhs-1
local a = ('string' and 53) + 42
--! ok
--8<-- conjunctive-lhs-2
local a = (53 and 'string') + 42 --@< Error: Cannot apply + operator to `"string"` and `42`
--@^ Cause: `"string"` is not a subtype of `number`
--! error
.