rokucommunity / rokucommunity/brighterscript
Null-coalescing transpilation can cause problems in print statements
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 208
- Forks
- 68
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 39
Description
Consider:
print "Values:" data.values ?? []
transpiles to:
print "Values:" (function(data)
__bsConsequent = data.values
if __bsConsequent <> invalid then
return __bsConsequent
else
return []
end if
end function)(data)
this transpilation causes a run-time error:
Function Call Operator ( ) attempted on non-function. (runtime error &he0)
however, if it is preceded with a semi-colon, then it does not have any problem.
print "Values:"; data.values ?? []
gives:
print "Values:"; (function(data)
__bsConsequent = data.values
if __bsConsequent <> invalid then
return __bsConsequent
else
return []
end if
end function)(data)
If any self-invoking function in transpilation (eg. null-coalescing, ternary, etc.) is in a print statement.. it's probably best to precede it with a semi-colon.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided BrightScript print statement and inspect the transpilation path for null-coalescing and other self-invoking expressions inside print statements. Done means the example runs without the Function Call Operator runtime error while preserving the intended print behavior, including both separator forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100