[4.5] ZScript: Cannot push TextureID to array<TextureID>

Thu Jan 14, 2021 9:40 am

Consider the code:
Code:
array<TextureID> b;
TextureID t = TexMan.checkForTexture("titlepic", TexMan.Type_Any);

Straightforward attempt to populate the array won't succeed:
Code:
b.push(t);
Running a mod with such code results in error: "Numeric type expected, got a name".

However, casting TextureID to int works:
Code:
b.push(int(t));


So, it's possible to create an array of TextureIDs but it's impossible to fill it without type casting. This is inconvenient and looks hacky.

Questions:
1. Is a bug or ZScript limitation?
2. If it's a ZScript limitation, is it safe to cast TextureID to int? I see that C++ TextureID counterpart, FTextureID, consists of a single int, so for now type casting is probably safe. Will it remain so?

Runnable example:
textureid-array.pk3
You do not have the required permissions to view the files attached to this post.

Re: [4.5] ZScript: Cannot push TextureID to array<TextureID>

Thu Jan 14, 2021 9:43 am

Most likely this is an oversight in the type checking system. TEchnically casting between int and TextureID should be safe, it's just a type safe wrapper around an index.

Re: [4.5] ZScript: Cannot push TextureID to array<TextureID>

Fri Jan 15, 2021 8:56 am

Also see here for a similar report regarding arrays of names, which was for some reason closed as "Duplicate" without any further remarks. Is one of the developers a time traveler? :o :P

Re: [4.5] ZScript: Cannot push TextureID to array<TextureID>

Fri Jan 15, 2021 10:27 am

Player701 wrote:Is one of the developers a time traveler? :o :P

We all are. It's a perk. :twisted:

So's the Tardis but we keep those well hidden.

Re: [4.5] ZScript: Cannot push TextureID to array<TextureID>

Sat Jan 16, 2021 7:37 am

Huh, I remember that I reported it. Or I wanted to report it? Or that was on another forum?
Hmmmm, something really wrong with this reality. Time to jump to another dimension, before something bad happ