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

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
User avatar
m8f
 
 
Posts: 1467
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Location: Siberia (UTC+7)
Contact:

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

Post by m8f »

Consider the code:

Code: Select all

array<TextureID> b;
TextureID t = TexMan.checkForTexture("titlepic", TexMan.Type_Any);
Straightforward attempt to populate the array won't succeed:

Code: Select all

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: Select all

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
(627 Bytes) Downloaded 45 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

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.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

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

Post by Player701 »

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
User avatar
Rachael
Posts: 13967
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

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

Post by Rachael »

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.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

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

Post by Apeirogon »

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
Post Reply

Return to “Bugs [GZDoom]”