Table of Contents

5.4.2.17 Exit Sub Statement

Note

This section describes the implementation of MS-VBAL §5.4.2.17 Exit Sub Statement.

Syntax

AST node Instruction kind Notes
KeywordStatementNode (Token: "Exit Sub") ExitProcedure No resolved target.

Exit Sub, Exit Function and Exit Property all lower to the InstructionKind ExitProcedure (RD-VBAL §3.5.2 Instruction).

Static Semantics

An Exit Sub must be inside the body of a subroutine; in a Function or in a property it is VBC09332 (ExitSubNotAllowedInFunctionOrProperty). The rule is ExitStatementStaticSemantics's, applied when the kind of the procedure is known (RD-VBAL §5.4.2.18 Exit Function Statement).

Runtime Semantics

The executor dispatches the ExitProcedure instruction, which completes the current activation.

Reaching the end of the instruction list completes the activation "as if execution had reached the end of the body" (the wording of MS-VBAL §5.4.2.17). This is the same outcome as an explicit Exit (RD-VBAL §3.5.4 Execution).

Implementation

  • RDCore.Runtime.Execution.ProcedureExecutor dispatches ExitProcedure instructions.

⏮️ RD-VBAL §5.4.2.16 On...GoSub Statement | ⏭️ RD-VBAL §5.4.2.18 Exit Function Statement