Closed tinkerer-red closed 1 year ago
bool( array_var )
has always been an error... I have no plans on changing that, this is the same code that handles the implicit conversion to boolean so it is an error.
What's the logic for having the others returning as true then? Like I could understand if a struct if they made use of valueOf
, and kind of also could understand functions given they use to be an index reference and it's for legacy support. Are these intentional choices or were grandfathered in from prior code?
we wanted to leave the valueOf
route open, functions used to be integers, methods are structs... they were all intentional choices - we made an array an error as it used to valid code to see an array variable being used without the deference and GM7 and GM8 actually did the dereference for you automatically i.e. a
and a[0]
were the same thing. We want to discourage that (we still see users migrating old code and we want them to fix it)
Description
When passing an array into an
if
expression the game crashes, I am unsure if this is intended given arrays are simply refs, as well as structs, and methods. If structs, functions, and methods all pass the if statement, logically arrays would as well.test code:
I originally thought that this was because internally they had made use of
valueOf
to return true, although whenreal()
the struct and method returnedNaN
which fails in if expressions. So there seems to be another approach going on which manually approved these specifically.EDIT : It is using
bool()
internally, obviously. I dont know how I forgot about that function.Expected Change
if (_arr)
expression should passSteps To Reproduce
copy paste code
How reliably can you recreate this issue using your steps above?
Always
Which version of GameMaker are you reporting this issue for?
2023.8.2 (Monthly)
Which platform(s) are you seeing the problem on?
Windows
Contact Us Package Attached?
Sample Project Added?