RDC11016 — Empty or Null assigned to an array
Severity: Warning · Family: RDC (Rubberduck Core analyzers) ·
Raised by: EmptyLetToArrayAnalyzer
The Empty or the Null literal is assigned to an array: a variable declared as one (Dim a() As Integer), or the result of a function that returns
one (Function F() As Integer()).
The code compiles: Empty and Null are Variant values, and a Variant may hold an array. But neither holds one, and the assignment raises run-time
error 13 (Type mismatch) every time it runs. This is what Microsoft Office VBA does, and what RD-VBA does
(RD-VBAL §5.5.1.1).
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A dynamic array is meant to be emptied. | a = Empty, a = Null |
Erase a. |
| A function that returns an array means to return no elements. | F = Empty, with F declared As Integer() |
Leave the result as it is (a dynamic array with no elements), or declare the function As Variant to return Empty. |
See also
- RD-VBAL §2.6.4 Rubberduck Core Diagnostics
- RD-VBAL §5.5.1.1 Static Semantics
VBR00013: Type mismatch
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca