Table of Contents

RDC01018: Keyword used as a member name

Severity: Information  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: KeywordUsedAsMemberNameAnalyzer

An Enum member or a member of a user-defined type is named with a keyword of the language.

A member of a user-defined type may be named with a keyword, such as Next or Loop (MS-VBAL §5.2.3.3 User Defined Type Declarations). An Enum member may be, when its name is written in brackets, such as [Select]: a name in brackets is a foreign name (MS-VBAL §3.3.5.3). Both compile. Code that uses such a member reads like the keyword, and an Enum member must be written in brackets wherever it is used without its Enum.

A keyword is a reserved-identifier (MS-VBAL §3.3.5.2 Reserved Identifiers and IDENTIFIER). A name that MS-VBA refuses or that differs from MS-VBAL, such as an Enum member named Date, is reported by RDC11033 or RDC11034 instead.

The finding is the name of the member.

How it is raised

Situation Example Resolution
A member of a user-defined type named with a keyword. Type Node
Next As Long
End Type
Rename the member: NextIndex.
An Enum member named with a keyword in brackets. Enum Clause
[Select] = 1
End Enum
Rename the member: SelectClause.

Quick fix

The diagnostic comes with a quick fix that renames the member, to the name you give, where it is declared and wherever it is used.

See also


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