Skip to main content

Overview

@operator tells GLuaLS what a class supports for operators like +, ==, #, indexing, or calling. Use it in annotation files or class definitions when GLuaLS cannot infer the operator behavior.

Syntax


Usage

Add the operator on the class before the local assignment or returned table:

Supported operators

  • Arithmetic: add, sub, mul, div, mod, pow, unm (unary minus)
  • Bitwise: band, bor, bxor, shl, shr, bnot
  • Other numeric: idiv
  • Relational: eq, lt, le
  • Other: len (length operator #), concat (concatenation ..), call, index
pairs is accepted in an annotation but does not change the types GLuaLS reports.