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
@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 realnil and NULL bugs.
See also
@valid_guard: a function that proves its argument is valid@self_call_valid: a callback where aselfmethod always returns a valid value