ZScript: Left hand side of Size must point to a class object

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
stan423321
Posts: 32
Joined: Tue Mar 25, 2014 2:35 pm

ZScript: Left hand side of Size must point to a class object

Post by stan423321 »

I'm not even sure how to comment on this. Here's a minimal example. Following ZScript

Code: Select all

version "3.4"

class Foo {
	uint Bar(Array<Object> arr) {
		return arr.Size();
	}
}
errors out with

Code: Select all

Script error, "arraybug.pk3:zscript.txt" line 5:
Left hand side of Size must point to a class object
Wrapping the array in an object worked for now in the actual project, but adds to boilerplate. I assume that this is a bug since... why would one allow dynarray parameters otherwise? Found on 3.6.0, retested on 3.7.pre-9-g4ac43dac, both 64-bit. Do we need specs for this?
Attachments
arraybug.pk3
Nothing but ZScript in the post is in this mod.
(245 Bytes) Downloaded 70 times
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

Re: ZScript: Left hand side of Size must point to a class ob

Post by m8f »

It seems that when the dynamic array is passed as a parameter, it is considered a value of type Pointer<DynArray<something>> instead of just DynArray<something>.
stan423321
Posts: 32
Joined: Tue Mar 25, 2014 2:35 pm

Re: ZScript: Left hand side of Size must point to a class ob

Post by stan423321 »

Hmm. Is that a hint to engine developers, or something I'm supposed to unwrap myself?
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: ZScript: Left hand side of Size must point to a class ob

Post by gramps »

Huh, that's weird...

Just searching the git repo, it looks like the error comes from here, and as far as I can tell tracking it back from there, it can't convert that array pointer to a container, because it doesn't have a "TYPE_Container" flag. An array sounds like a container to me, and i guess pointers are supposed to be automatically dereferenced, so it looks like an oversight (or just not implemented yet).

Can also confirm what m8f said; try adding Array<Object> qux; qux = arr;
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript: Left hand side of Size must point to a class ob

Post by Graf Zahl »

The real issue here is the error message. The VM cannot take arrays as pointers so they cannot be passed as parameters directly unless wrapped into a class.
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: ZScript: Left hand side of Size must point to a class ob

Post by phantombeta »

Duplicate of this report. (Yes, this one was posted first, but the other one got closed first.)
Post Reply

Return to “Closed Bugs [GZDoom]”