Ask <sprite> for <my name> result inconsistent

This is in Ver 0.6.0 beta.

I am using for an existing Sprite B1:
image
image
and getting the correct answer.

Then I wanted to use the same logic to test if sprite of a particular name existed or not, by using B5 (non-existing):
image
image
Which returns no answer, assuming because there is no sprite with that name.

If I execute this second ASK block by clicking on it, it comes back immediately.
But if I put it into a SAY block or try to assign it to a variable or even try to check it's length, then the block goes into an endless loop, trying to resolve the name.
image

  • Why is that?
  • Should it not return immediately with an empty STRING as name, or some equivalent value?

I then tried the same using OBJECT block with name variable: image
It was a bit better since I got a blank return. And I thought I could use that instead. So I assigned the OBJECT reporter to my result var.

At this point something different but strange happens:
image

"result" var was displaying the value 0 in the programming area, which I liked. But the "result reporter" on screen was showing no value. I verified this by first setting result = 0 and the on screen reporter showed 0. Then executing the "set result to object name" block, set the reporter value on screen to nothing.
image

Is this normal or a bug of sorts?

It's a misfeature. We don't do much type checking of values, so for the most part the things that Javascript represents internally as 0 are interchangeable. We're somewhat more careful about list inputs and Boolean inputs. The trouble is that being strict about type checking would slow Snap! down too much.

I think your answer is to second half of my question re OBJECT block. I understand that part.
Does it also apply to the first part re endless LOOPING of the ASK block?

Right, sorry, the getting into a loop does indeed sound like a bug!

@bh:

Does this mean it is reported and will be taken care of?
Or should I report it under bugs?

It'll probably be seen a little faster on github.