RDC00307: Obsolete type hint
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: ObsoleteTypeHintAnalyzer
A name is written with a type-declaration character - x%, name$, total& - where an As clause at its declaration states the type.
A character after a name says the type of what it names (MS-VBAL §3.3.5.3): % is an Integer, & a Long, $ a String. An As clause says it in a word, in the place a
reader looks for it, and there is a character for only some of the types. The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal.
What is reported:
- the declaration of a variable, a constant, a parameter or a function that is written with the character, where its name is written;
- a reference to a name that is written with it, alone (
gCount%) or as the member of a member access (Globals.gCount%), when the host vouches that the name is bound to a declaration of the project, in the module or in another (ExpressionFact.Binding): the declaration is what is changed to get rid of it.
A reference to a member of a library, such as Mid$ or Error$ of the standard library, has no declaration of the project's to change: it is not reported, and
neither is a reference that the host did not bind. It is a suggestion because stating the type with an As clause does not change what the declaration is.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A variable, a constant, a parameter or a function is declared with the character. | Dim count% |
Write the type: Dim count As Integer. |
| A name that is declared in the project is referred to with the character. | count% = 1, or gCount% = 1 and Globals.gCount% = 1 with Public gCount% in Globals |
Refer to it by its name: count = 1. |
See also
- RD-VBAL §2.6.4 Rubberduck Core Diagnostics
- RDC00201:
As Integeror%
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca