Docs
Linting rules

S002: explicit-return-type

Requires explicit return types for function declarations.

Metadata

  • Code: S002
  • Rule: explicit-return-type
  • Status: Stable since v0.0.1
  • Quick fix: sometimes available

What it does

Requires explicit return types for function declarations.

Why is this bad?

Omitting return types makes APIs less clear and can hide accidental signature changes.

Example

fun buildSlice() {
S002: function return type should be explicit
return beginCell().toSlice(); }

Use instead:

fun buildSlice(): slice {
    return beginCell().toSlice();
}

Behavior notes

  • Contract entrypoints main, onInternalMessage, onExternalMessage, onRunTickTock, onSplitPrepare, onSplitInstall, and onBouncedMessage are ignored by this rule.
  • Functions whose inferred return type is void are ignored by this rule.
Source code

Last updated on

On this page