Structs may not be nested inside structs, only classes

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: Structs may not be nested inside structs, only classes

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

by Graf Zahl » Tue Aug 28, 2018 11:32 am

This is certainly an oversight. The compiler backend can definitely handle such constructs, but it seems the grammar is incomplete.

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

by Major Cooke » Tue Aug 28, 2018 11:08 am

Code: Select all

Class aa
{
	Struct bb
	{
		int volt;
	};
}
Oooh, I see now. Huh. Didn't even know that was doable. TIL!

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

by phantombeta » Tue Aug 28, 2018 11:02 am

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.

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

by Major Cooke » Tue Aug 28, 2018 10: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.

Structs may not be nested inside structs, only classes

by argv » Mon Aug 27, 2018 3: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.

Top