[ZScript] Recursively returning multiple values

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: [ZScript] Recursively returning multiple values

Re: [ZScript] Recursively returning multiple values

by Graf Zahl » Fri Dec 21, 2018 5: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.

Re: [ZScript] Recursively returning multiple values

by _mental_ » Fri Dec 21, 2018 5: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.

Re: [ZScript] Recursively returning multiple values

by Graf Zahl » Fri Dec 21, 2018 4: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.

Re: [ZScript] Recursively returning multiple values

by _mental_ » Fri Dec 21, 2018 4:15 am

This was already reported here.

[ZScript] Recursively returning multiple values

by Talon1024 » Fri Dec 21, 2018 2: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 all

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 all

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.

Top