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

These bugs do plan to be resolved, when they can be.

Moderator: GZDoom Developers

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

Postby stan423321 » Sun Oct 21, 2018 11:33 am

I'm not even sure how to comment on this. Here's a minimal example. Following ZScript
Code: Select allExpand view
version "3.4"

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

errors out with
Code: Select allExpand view
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 15 times
stan423321
 
Joined: 25 Mar 2014

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

Postby m8f » Mon Oct 22, 2018 10:09 am

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>.
User avatar
m8f
 
 
 
Joined: 29 Dec 2017
Discord: m8f#0629
Github ID: mmaulwurff

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

Postby stan423321 » Tue Oct 30, 2018 1:06 pm

Hmm. Is that a hint to engine developers, or something I'm supposed to unwrap myself?
stan423321
 
Joined: 25 Mar 2014

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

Postby gramps » Tue Oct 30, 2018 9:36 pm

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;
gramps
 
Joined: 18 Oct 2018

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

Postby Graf Zahl » Wed Oct 31, 2018 12:29 pm

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
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to On Hold Bugs

Who is online

Users browsing this forum: No registered users and 1 guest