Menu

#319 Include constness in member sub/function/property signature

open
nobody
None
2025-10-12
2025-10-12
Rule
No

In the following code, FreeBASIC considers the second declarations of Bar a duplicate. This suggests that the constness of the hidden This parameter is not included in the signature, or perhaps that This is not included at all.

Type Foo
    Declare Const Property Bar As sometype
    Declare Property Bar As sometype
''  Other stuff...
End Type

For comparison, this compiles without problem:

Type Foo
''  Other stuff...
End Type
Declare Function Bar Overload (ByRef This As Const Foo) As sometype
Declare Function Bar Overload (ByRef This As Foo) As sometype

Including the constness of This in the signature would allow overloading members for constant and non-constant instances.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.