[ZScript] Recursively returning multiple values

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!

[ZScript] Recursively returning multiple values

Postby Talon1024 » Fri Dec 21, 2018 3:15 am

It looks like the ZScript VM cannot recursively return multiple values from a function that returns multiple values. For example, switching to the next or previous weapon while there is a pending weapon does not work as expected. The real issue seems to be in zscript/shared/player.txt on line 1927.

Apparently, this works properly:
Code: Select allExpand view
if (player.PendingWeapon != WP_NOCHANGE)
{
   bool found;
   int slot;
   int index;
   [found, slot, index] = player.weapons.LocateWeapon(player.PendingWeapon.GetClass());
   return found, slot, index;
}


But this code, which is currently being used, does not:
Code: Select allExpand view
if (player.PendingWeapon != WP_NOCHANGE)
{
   return player.weapons.LocateWeapon(player.PendingWeapon.GetClass());
}


Note that I am NOT using the JIT compiler, as I don't quite trust it to be stable enough for everyday use yet.
Talon1024
 
 
 
Joined: 27 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Recursively returning multiple values

Postby _mental_ » Fri Dec 21, 2018 5:15 am

This was already reported here.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: [ZScript] Recursively returning multiple values

Postby Graf Zahl » Fri Dec 21, 2018 5:46 am

This one's more descriptiv, though. However, since I currently have no idea how to handle this, I changed the problem code to use the above workaround.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: [ZScript] Recursively returning multiple values

Postby _mental_ » Fri Dec 21, 2018 6:08 am

But this won't prevent usage of the same broken code in mods. Fixing core script without prohibiting re-return of multiple values seems a bit fragile.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: [ZScript] Recursively returning multiple values

Postby Graf Zahl » Fri Dec 21, 2018 6:12 am

I know, but the last time a fix was attempted it didn't work out. The report needs to remain open but that alone is no reason to leave the non-functional code in.
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: _mental_ and 2 guests