rokucommunity / rokucommunity/brighterscript

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

Open
#772 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
208
Forks
68
Avg merge
8h 39m
Merged PRs (30d)
39

Description

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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docs/callfunc-operator.md, especially the documented no-argument evaluation section, then trace bsc’s @/callfunc transformation for myComponent@.myFunction(). Done means the generated callfunc argument honors the function’s declared default instead of emitting invalid, with coverage for the example behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.