Default Member Required

Locates indexed default member calls for which the corresponding object does not have a suitable suitable default member.

Reasoning

The VBA compiler does not check whether the necessary default member is present. Instead there is a runtime error whenever the runtime type fails to have the default member.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

Class1 (ClassModule)
Public Function Foo(index As Long) As Long 'No default member attribute End Function
Module1 (StandardModule)
Public Sub DoIt() Dim cls As Class1 Dim bar As Variant Set cls = New Class1 bar = cls(0) End Sub

This example should NOT trigger a result

Class1 (ClassModule)
Public Function Foo(index As Long) As Long Attribute Foo.UserMemId = 0 End Function
Module1 (StandardModule)
Public Sub DoIt() Dim cls As Class1 Dim bar As Variant Set cls = New Class1 bar = cls(0) End Sub

Rubberduck.CodeAnalysis.Inspections.Concrete.DefaultMemberRequiredInspection.cs (Prerelease-v2.5.9.6289)