[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!

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

Postby m8f » Thu Jan 14, 2021 9:40 am

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

Straightforward attempt to populate the array won't succeed:
Code: Select allExpand view
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 allExpand view
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.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit

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

Postby Graf Zahl » 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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Player701 » 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
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

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

Postby Rachael » 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.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

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

Postby Apeirogon » 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
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017


Return to Bugs

Who is online

Users browsing this forum: No registered users and 0 guests