Gwynge
Gwynge

Reputation: 160

Not returning a value that is a Structure does not generate a Warning

In the following code:

    Public Structure MyDate
    Public year As Integer
    Public month As Integer
End Structure

Public Function GetMyDate() As MyDate

End Function

Public Function GetSystemDate() As Date

End Function

Public Function GetListview() As ListView

End Function

Public Function GetInteger() As Integer

End Function

Visual Studio 2015 issues warnings that GetSystemDate, GetListview and GetInteger "doesn't return a value on all code paths" but it is silent on GetMyDate.

Is there a sensible reason for this or perhaps it's a bug?

Upvotes: 3

Views: 56

Answers (1)

TnTinMn
TnTinMn

Reputation: 11801

A similar bug (for all structures) was reported several years ago (see:BC42105 does not fire for structures) and supposedly fixed for VS2010.

Contrary to what I posted in the comments section, this bug is not limited to user defined types. It appears that any structure that is not a numeric type will suffer this from this bug. For instance, this will also not yield a warning.

Function colr() As System.Drawing.Color
End Function

Upvotes: 3

Related Questions