rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
153 stars 47 forks source link

How to handle integers passed as booleans to a function #1168

Closed TwitchBronBron closed 2 months ago

TwitchBronBron commented 2 months ago

image

This is valid code. When a boolean field is given a number, 0 means false and everything else means true. How should we handle this in the v1 type system? Is it an error?

TwitchBronBron commented 2 months ago

Looks like brightscript casts integer and float values into booleans. So...should we make all numbers assignable to booleans...but only when calling functions?

image image

TwitchBronBron commented 2 months ago

This is also supported in conditional expressions when comparing numbers and booleans.

image