Table of Contents

Class ExitStatementStaticSemantics

Namespace
RDCore.SDK.Semantics.Static
Assembly
RDCore.SDK.dll

Where an Exit statement may be written: MS-VBAL §5.4.2.5 (Exit For), §5.4.2.7 (Exit Do), §5.4.2.17 (Exit Sub), §5.4.2.18 (Exit Function) and §5.4.2.19 (Exit Property).

public static class ExitStatementStaticSemantics
Inheritance
ExitStatementStaticSemantics
Inherited Members

Remarks

The rule is stated once, here, because two walkers of a procedure body each have the position it depends on - the loops around the statement, and the kind of procedure it is in - and both have to agree on it: StatementStaticSemanticsEvaluator, and InstructionListLowering, the pass that actually reports the errors of a module as it is loaded.

An Exit For or Exit Do must be lexically inside a loop of its kind, at any depth: an Exit For in a Do loop that is itself in a For loop is the For loop's.

👉 Exit Function is also accepted in a Property Get. MS-VBAL §5.4.2.18 says it must be in a function, but MS-VBA accepts it in a property getter (see ExitFunctionNotAllowedInSubOrProperty), and a program written against MS-VBA relies on that.

Methods

Evaluate(KeywordStatementNode, bool, bool, MemberKind?)

Checks one Exit statement against the position it is written in.

public static VBCompileErrorInfo? Evaluate(KeywordStatementNode exit, bool withinFor, bool withinDo, MemberKind? procedure)

Parameters

exit KeywordStatementNode

The statement. Anything that is not an Exit statement is valid.

withinFor bool

Whether the statement is lexically inside a For or For Each loop.

withinDo bool

Whether the statement is lexically inside a Do loop.

procedure MemberKind?

The kind of the procedure the statement is written in, or null when it is not known - the kind of procedure is not checked then.

Returns

VBCompileErrorInfo

The error, or null when the statement is where it may be.