sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
114 stars 43 forks source link

fix(interpreter): allow dynamic functions to return void #602

Closed lkipke closed 3 years ago

lkipke commented 3 years ago

Change Summary

Currently, when a function uses return without a value, we treat it as returning void. This is a problem for functions with a dynamic return type, because void is currently not accepted as a valid return type for dynamic functions. This PR enables dynamic functions to accept void as a return type.

Alternatively, we could instead evaluate return as return invalid; but this would require additional logic to handle this case for subs, which (because they're void functions) are only supposed to accept void return types.

lkipke commented 3 years ago

It turns out that RBI doesn't allow an empty return in a function using the function keyword -- it causes a compile error. So this is not a bug, but a feature 😉