Table of Contents

RDC00102 — Implicit non-default array base

Severity: Hint  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: OptionBaseAnalyzer

A module states Option Base 1.

The directive changes the lower bound of every array of the module that is declared without one, from 0 to 1 (MS-VBAL §5.2.1.2 Option Base Directive). The arrays that other modules and libraries give it keep their own bounds, so what an index means depends on where the array comes from, and a reader cannot tell from a declaration like Dim items(5) how many elements it has without looking at the top of the module. The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal VBA.

Not even every array of the module follows it: an array field of a user-defined type starts at 0 whatever the directive says, as it does in MS-VBA. Under Option Base 1, Dim items(5) is 1 To 5 and a field Items(5) As Long of a Type beside it is 0 To 5.

Option Base 0 states the default and is not reported.

That the module states the directive is a fact of the way it is written: the analyzer reads it off the syntax tree.

How it is raised

Situation Example Resolution
The module has an Option Base 1 directive. Option Base 1 Remove the directive, and state the bounds of each array that needs a lower bound of 1: Dim items(1 To 5).

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca