Skip to main content
This annotation is intended for complex cases and is primarily designed to be used by the built-in annotations.

Overview

self_guard marks a colon method such as Entity:IsValid that returns true only when the object it is called on is valid. After if ent:IsValid() then, GLuaLS treats ent as valid. The official annotations already mark IsValid on entities, panels and other Garry’s Mod objects.

Syntax

Put it after the @return or @return_cast line.

Example


Keep it narrow

It applies only to the annotated method. Only use it on a method that really checks validity, or it hides real nil and NULL bugs.

See also