lloyAlloy on GitHub
TraitContract
Docs

TraitContract

Updated

The rule behind this error is on the Structs and traits page.

struct Name
    field: T
end

A record with fields. impl Name adds methods. new Name { x = 1 } fills the fields and new Name(...) calls Name.new; a construction always takes new. @derive(Eq, Debug, Clone) on the line before generates methods. A field or a method marked private belongs to the impl alone.

Emits a table type plus a metatable with __index and a __tostring, so print(v) and `{v}` show Name { x = 1, y = 2 }. A to_string in the impl, an impl Display, replaces the default printer.

The word is also free as a name. struct before a name on the same line declares; local struct = {} and struct.x = 1 read the Luau way.