Skip to content

@/callfunc transformation should honor the default values of a function #772

@ZeeD

Description

@ZeeD

first of all: the current behavior is totally documented, you can treat this as a "feature request"/improvement.

Let's say I have this function in my component

sub myFunction(myFlag = true as boolean)
...
end sub

and I try to invoke it from the external with the @ syntax. I don't pass any value so I assume that myFlag is set to true

myComponent@.myFunction()

but bsc compiles the snippet to

myComponent.callfunc("myFunction", invalid)

witch translates to the runtime error: Type Mismatch. Unable to cast "roInvalid" to "Boolean".

Ideally, instead, the translation of @ should check if the first value of the function has a default value, and use it. In this case compiling to

myComponent.callfunc("myFunction", true)

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