Structs may not be nested inside structs, only classes

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!

Structs may not be nested inside structs, only classes

Postby argv » Mon Aug 27, 2018 4:15 pm

I'm not sure if this is intentional, but I notice that while structs can be nested inside classes, they cannot be nested inside other structs.

Because nesting can be helpful for reducing the chance of namespace collisions, please consider allowing that.
argv
 
Joined: 30 Aug 2016

Re: Structs may not be nested inside structs, only classes

Postby Major Cooke » Tue Aug 28, 2018 11:47 am

If that were true, Line structs wouldn't be able to store Vertex structs and so on. But then again, they're native...

Are you trying to store structs of the same type into itself? Try making it 'readonly'. That's how the Sector struct does it with the heightsec variable which is also a Sector struct.

No guarantees it'll work, that's just a theory.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Structs may not be nested inside structs, only classes

Postby phantombeta » Tue Aug 28, 2018 12:02 pm

No. He's talking about defining structs inside structs.
I'm pretty sure this is intentional. There's nothing in the ZScript syntax to allow structs nested in structs.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Structs may not be nested inside structs, only classes

Postby Major Cooke » Tue Aug 28, 2018 12:08 pm

Code: Select allExpand view
Class aa
{
   Struct bb
   {
      int volt;
   };
}


Oooh, I see now. Huh. Didn't even know that was doable. TIL!
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Structs may not be nested inside structs, only classes

Postby Graf Zahl » Tue Aug 28, 2018 12:32 pm

This is certainly an oversight. The compiler backend can definitely handle such constructs, but it seems the grammar is incomplete.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest