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

Skip to content

Arrays cannot be accessed within UDT methods (TB5078) #2323

@KubaO

Description

@KubaO

Describe the bug
When attempting to use an array within a method in a UDT, TB5078 is raised.

To Reproduce

Module MainModule
    Type MyType
        dummy&
        
        Function F() As Single()
            Dim result(1 To 6) As Single
            result(2) = 1         ' <---- TB5078 Error occurred in binding to symbol 'result'
            Return result         ' <---- TB5078 Error occurred in binding to symbol 'result'
        End Function
        
        Function G() As Single()
            Dim result(1 To 6) As Single
            result(2) = 1         ' <---- TB5078 Error occurred in binding to symbol 'result'
            G = result            ' <---- TB5078 Error occurred in binding to symbol 'result'
        End Function
    End Type

    Function F() As Single()
        Dim result(1 To 6) As Single
        result(2) = 1         ' OK
        Return result         ' OK
    End Function
    
    Function G() As Single()
        Dim result(1 To 6) As Single
        result(2) = 1         ' OK
        G = result            ' OK
    End Function
End Module

Expected behavior
No error occurrs.

Desktop (please complete the following information):

  • twinBASIC Beta 973 and 964

Additional context
I've run into that when working on the GdiPlus package.

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