Skip to main content

Overview

@nodiscard marks a function whose return value callers should use. If you call the function and ignore the return value, GLuaLS reports discard-returns.

Syntax


Usage


With a custom message

Add a string to explain why the return value matters:
The message appears in the diagnostic.

When to use

Use @nodiscard on functions where:
  • Ignoring the return value is usually a bug, such as getting a handle or a result you must check
  • Callers must manage work tied to the return value, such as cleanup or cancellation
Common candidates in GMod:
  • Functions returning an Entity that the caller is expected to configure
  • Functions returning a success boolean
  • Token or handle-returning functions