
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
exit for inside try catch results in unexpected behavior
I'm finding that exit for, inside of try catch give a strange stack trace. The exit for is legit, in this code, and the code behaves as expected, if the try catch block is removed
https://georgejecook.github.io/
https://linkedin.com/in/georgejecook/
Roku developers slack group (https://join.slack.com/t/rokudevelopers/shared_invite/zt-4vw7rg6v-NH46oY7hTktpRIBM_zGvwA) : georgejecook
Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: exit for inside try catch results in unexpected behavior
Hey George,
What specific use case for TRY/CATCH are you working on...please advise so I can see how we can best help you.
Thanks,
Jonathan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: exit for inside try catch results in unexpected behavior
George - this should not be happening, not in relation to `try/catch` anyhow.
Please provide MWE to analyze, screenshot alone was no help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: exit for inside try catch results in unexpected behavior
Confirming - issue exists when EXIT FOR is used in FOR EACH loop nested in a TRY/CATCH statement. Other loops (numeric FOR, WHILE) are not affected.
Minimalist repro:
Brightscript Debugger> try: for each i in [1]: ? i: exit for: end for: catch e: ? "except", e: end try 1 UNEXPECTED INTERNAL. (runtime error &hfe) in $LIVECOMPILE(703)
Behavior: "Unexpected internal" error at runtime, when EXIT FOR is to be executed.
Notice this only happens for syntactical nesting of FOR EACH inside TRY/CATCH within the same function, it won't happen if TRY/CATCH is further down in the call stack, e.g.
Brightscript Debugger> proc = sub(): for each i in [1,2]: ? i: exit for: end for: divZero = 1/0: end sub Brightscript Debugger> try: proc(): catch e: ? "except", e: end try 1 except <Component: roAssociativeArray> = { backtrace: <Component: roArray> message: "Divide by Zero." number: 20 rethrown: false }
Workaround: avoid nesting TRY > FOR EACH > EXIT FOR within the code of a single function. Use WHILE > EXIT WHILE or FOR-TO > EXIT FOR or boolean flag where feasible. Or separate TRY/CATCH from FOR EACH > EXIT FOR with a nested call.
Stay tuned for a fix.