The prefix increment and decrement operators (++x and --x) are broken.
Summon "TestActor" while running GZDoom with the example WAD to test it.
[ZScript] Prefix increment and decrement are broken
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.
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.
- phantombeta
- Posts: 2089
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
[ZScript] Prefix increment and decrement are broken
- Attachments
-
- BrokenOperator.pk3
- (248 Bytes) Downloaded 24 times
Re: [ZScript] Prefix increment and decrement are broken
Prefix operators abort VM execution only if they are used directly in string format functions. I would say this is not implemented rather than broken.
From topic's title it seems that they don't work at all.
From topic's title it seems that they don't work at all.
- phantombeta
- Posts: 2089
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: [ZScript] Prefix increment and decrement are broken
It isn't just "only if they are used directly in string format functions"
This doesn't work either. Should print 16, but prints a number that changes every time you start the game.
Code: Select all
version "3.2"
class TestActor : Actor {
states {
Spawn:
TNT1 A 1;
TNT1 A 1 {
int i = 15;
Console.Printf ("i: %d", lol (++i));
}
stop;
}
int lol (int a) { return a; }
}
- Marisa the Magician
- Posts: 3886
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
- Contact:
Re: [ZScript] Prefix increment and decrement are broken
I guess we can say that vararg functions are kinda wonky then.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49071
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Prefix increment and decrement are broken
No not varargs. It was preincrementing a local variable and passing the result as a function parameter that caused the bug.