Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(interp): Automatically box return values for 'as object' return types #360

Merged
merged 1 commit into from
Jan 21, 2020

Conversation

sjbarag
Copy link
Owner

@sjbarag sjbarag commented Jan 21, 2020

RBI will automatically box an intrinsic value when it's returned from a function that declares an as object return type. This makes the function behave quite similarly to an as dynamic function, in that it can seemingly return any value. The only difference is that as dynamic won't automatically box something like return false into an roBoolean, while the as object variant will!

fixes #359

…ypes

RBI will automatically box an intrinsic value when it's returned from a
function that declares an `as object` return type.  This makes the
function behave quite similarly to an `as dynamic` function, in that it
can seemingly return any value.  The only difference is that
`as dynamic` won't automatically box something like `return false` into
an `roBoolean`, while the `as object` variant will!

fixes #359
@sjbarag sjbarag added bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior interpreter Affects this project's tree-walking interpreter e2e Affects this project's end-to-end test cases (the BrightScript sample files executed during testing) labels Jan 21, 2020
Copy link
Collaborator

@strattonbrazil strattonbrazil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

@sjbarag
Copy link
Owner Author

sjbarag commented Jan 21, 2020

(oh you already approved!)

@sjbarag sjbarag removed the request for review from strattonbrazil January 21, 2020 21:14
@sjbarag sjbarag merged commit c214679 into master Jan 21, 2020
@sjbarag sjbarag deleted the auto-box-return-values-from-as-object branch January 21, 2020 21:15
lvcabral referenced this pull request in lvcabral/brs-engine Mar 11, 2020
…ypes (#360)

RBI will automatically box an intrinsic value when it's returned from a
function that declares an `as object` return type.  This makes the
function behave quite similarly to an `as dynamic` function, in that it
can seemingly return any value.  The only difference is that
`as dynamic` won't automatically box something like `return false` into
an `roBoolean`, while the `as object` variant will!

fixes #359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior e2e Affects this project's end-to-end test cases (the BrightScript sample files executed during testing) interpreter Affects this project's tree-walking interpreter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Interpreter): Functions with return type object don't auto-box return values
2 participants