Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Overload resolution fails on UDT types (TB5073) #2322

@KubaO

Description

@KubaO

Describe the bug
When calling overloaded UDT methods, the different UDT argument types cannot be disambiguated.

To Reproduce
The code below triggers TB5073 on rg.Intersect calls. If GpRegion were a Class, not a UDT, this problem wouldn't occur.

Module MainModule
    Type GpRect
        dummy&
    End Type
    
    Type GpRectF
        dummy!
    End Type
        
    Sub test(rect As GpRect, rectf As GpRectF)
        Dim rg As GpRegion
        rg.Intersect(rect)          ' <----- TB5073
        rg.Intersect(rectf)         ' <----- TB5073
    End Sub
    
    Type GpRegion
        dummy&
        
        Sub Intersect(rect As GpRect)
        End Sub
    
        Sub Intersect(rect As GpRectF)
        End Sub
    End Type
End Module

Expected behavior
Overload resolution succeeds and TB5073 is not triggered.

Desktop

  • twinBASIC beta 964

Additional Context
Having this working would make my GdiPlus package easier to use :)

Small print because this is a solved problem for Classes it seems. Make sure to have good test cases that cover previously working overload resolution before changing anything. This stuff is super easy to break in my limited experience, and the proper algorithm to do it requires a formal specification. If the C++ standard is anything to go for, that can be a solid book chapter in its own right. That's a lot of work that's not exactly necessary before v1 or to keep VB compatibility. If it's a true bug/omission/low hanging fruit, it's worth fixing before v1. Otherwise, I'd leave it be until after v1. It's not a deal breaker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions