"out Array<X>" parameters are not checked against the scoping system

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!
User avatar
phantombeta
Posts: 2113
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

"out Array<X>" parameters are not checked against the scoping system

Post by phantombeta »

out parameters with a dynamic array type aren't (properly?) checked against the scoping system. This breaks the scoping system and lets mods do things they shouldn't, intentionally or accidentally, and can cause very non-obvious and potentially hard to diagnose desync bugs.

Repro:

Code: Select all

class Test : Actor {
    int varA;
    Array<int> varB;

    clearscope void Foo (out int a) { a++; }
    clearscope void Bar (out Array<int> b) {
        let toPush = 0;
        if (b.Size () > 0)
            toPush = b [b.Size () - 1] + 1;
        b.Push (toPush);
    }

    ui void UIFunc () {
        varA++; // ERROR: Argument must be a modifiable value
        varB.Push (1234); // ERROR: Readonly struct on left hand side of Push not allowed

        Foo (varA); // ERROR: Argument must be a modifiable value
        Bar (varB); // !!No error!!
    }
}

Return to “Bugs [GZDoom]”