ID:72154
 
BYOND Version:440
Operating System:Windows XP Home
Web Browser:Firefox 3.0.10
Status: Deferred

This issue may be low priority or very difficult to fix, and has been put on the back burner for the time being.
Descriptive Problem Summary:
When using : with a variable that has been typecast as something (anything. any datum will do), using : will not recognize user-defined variables of another type.

Numbered Steps to Reproduce Problem:
1: create a user-defined variable
2: create a variable and typecast it (as anything other than the object with the user-defined variable)
3: assign it an object of that type (optional)
4: use : to access the user-defined variable
5: compiler error, yay

Code Snippet (if applicable) to Reproduce Problem:
mob
var
variablex

verb
test()
var/obj/testy = src
src << testy:variablex


Expected Results:
It'd do what it's supposed to do.

Actual Results:
It doesn't.

Does the problem occur:
Every time? Or how often? Yes.
In other games? Yes.
In other user accounts? Maybe.
On other computers? Possibly.

When does the problem NOT occur?
When the object is either (a) not typecast as something other than the object we're trying to access (b) not typecast at all

Workarounds:
Create a new variable that is typecast properly so we can access it one single time when we've already clarified that the object is of the type we want it to be.

Or don't typecast it at all. Which I would rather not do.

This is what I'm doing:
var/super_parent/super_parent = (super_parent/parent/child)
if (is_child) super_parent = super_parent:parent
if (is_parent) super_parent = super_parent:super_parent
if (!is_super_parent) return // failed to return a super parent

// use the super parent

Except with so much more detail.
This only happens when the type path for the var is from a different type path tree, like in the example above testy is defined as an obj but the var belongs to a mob. Because this is likely to be a difficult-to-find compiler issue, this may be better off deferred, but for now the issue has been marked as verified. The bug exists in 440 as well, so the issue has been edited to reflect that.
I always thought this was intended behavior o.O
It doesn't look like intended behavior to me, but if you can find a section in the guide or reference explaining it as such, I'd be more than happy to write it off as a non-bug.
Falacy wrote:
I always thought this was intended behavior o.O

: is supposed to "search" for the variable. The fact that it will not search for user-defined variables on a varlabe that has been typecast as another object when it works perfectly fine in any other situation makes absolutely no sense.

"This is the runtime search operator. It is used to access a property of a var that is not explicitly prototyped."

It only doesn't find user-defined variables of another type. That wouldn't make any sense to be intended.