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

Handle function does not return something edge case #1334

Open
TwitchBronBron opened this issue Oct 20, 2024 · 0 comments
Open

Handle function does not return something edge case #1334

TwitchBronBron opened this issue Oct 20, 2024 · 0 comments
Assignees

Comments

@TwitchBronBron
Copy link
Member

I think #1299 needs to be refactored. This function is sub as object, but does not return anything. However, when I print it, it returns 0. So it should not have an error in brighterscript because it does not cause a runtime error.

sub RedLines_AddLine(id, position, coords, node, childMap) as object
  line = CreateObject("roSGNode", "Rectangle")
  line.setField("id", id)
end sub

From what I can tell, functions as <something> will return invalid, and the runtime crash happens when it cannot convert invalid to the actual return data type:

  • as object is fine because it converts invalid to 0
  • as integer, as longinteger, as float, as double are all fine because they convert invalid to 0
  • as boolean is fine because it converts invalid to false

So really, #1299 should only show an error when the return type of invalid cannot be coerced into the return type, and that appears to exclusively be the string return type.

I'm thinking that diagnostic should actually be renamed to "Function will return invalid which cannot be coerced into `.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants