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

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!

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: [4.5] ZScript: Cannot push TextureID to array<TextureID>

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

by 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

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

by 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.

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

by 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

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

by 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.

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

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

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

Top