Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Add rule: no boolean type coersion #97

Open
cdthompson opened this issue Jun 13, 2018 · 1 comment
Open

Add rule: no boolean type coersion #97

cdthompson opened this issue Jun 13, 2018 · 1 comment

Comments

@cdthompson
Copy link

boolean type coersion is inconsistent. A rule to detect this would be helpful.

Motivation:

Brightscript Debugger> a = invalid

Brightscript Debugger> if a: print "hi": end if
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(8)

Brightscript Debugger> a = "true"

Brightscript Debugger> if a: print "hi": end if
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(10)

Brightscript Debugger> a = true

Brightscript Debugger> if a: print "hi": end if
hi

Brightscript Debugger> a = 1

Brightscript Debugger> if a: print "hi": end if
hi

Improved style allows for invalid without crashes (though string vs. boolean still crashes)

Brightscript Debugger> a = invalid

Brightscript Debugger> if a = true: print "hi": end if

Brightscript Debugger> a = "true"

Brightscript Debugger> if a = true: print "hi": end if
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(18)

Brightscript Debugger> a = 1

Brightscript Debugger> if a = true: print "hi": end if
hi
@nishtahir
Copy link
Member

Looks like this is something we should check as part of the main parser. Similar to how we check for duplicate function definitions. With limited information - we might only be able to do this for some types.

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

No branches or pull requests

2 participants