Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zephir bug in incrementing array element #2020

Closed
cryptooman opened this issue Dec 2, 2019 · 2 comments
Closed

Zephir bug in incrementing array element #2020

cryptooman opened this issue Dec 2, 2019 · 2 comments
Assignees
Labels

Comments

@cryptooman
Copy link

Hey. Seems found a bug in incrementing an array element in Zephir. Possible same presents also for the decrement.

array a = [0, 0, 1, 1];

let a[0] += 1; // 1

let a[1] = a[1] + 1; // 1

let a[2] += 1; // 1 <- expected 2

let a[3] = a[3] + 1; // 2

print_r(a);

Zephir 0.12.12, PHP 7.2.24-0ubuntu0.18.04.1

@sergeyklay sergeyklay self-assigned this Dec 2, 2019
sergeyklay added a commit that referenced this issue Dec 2, 2019
@sergeyklay sergeyklay added the bug label Dec 2, 2019
@cryptooman
Copy link
Author

cryptooman commented Dec 2, 2019

Please, check the same issue, but for the class static attributes.

namespace Test;
class TestBug
{
    private static _a;
    private static _b;

    public static function test() -> void
    {
        let self::_a = 0;
        let self::_b = 1;
        let self::_a += 1;
        let self::_b += 1;
        echo "test 1 _a: " . self::_a . " (epxect 1)\n";
        echo "test 1 _b: " . self::_b . " (epxect 2)\n"; // ?? 1

        let self::_a = 0;
        let self::_b = 1;
        let self::_a -= 1;
        let self::_b -= 1;
        echo "test 2 _a: " . self::_a . "  (epxect -1)\n"; // ?? 1
        echo "test 2 _b: " . self::_b . " (epxect 0)\n";

        let self::_a = 0;
        let self::_b = 1;
        let self::_a = self::_a + 1;
        let self::_b = self::_b + 1;
        echo "test 3 _a: " . self::_a . " (epxect 1)\n";
        echo "test 3 _b: " . self::_b . " (epxect 2)\n";

        let self::_a = 0;
        let self::_b = 1;
        let self::_a = self::_a - 1;
        let self::_b = self::_b - 1;
        echo "test 4 _a: " . self::_a . " (epxect -1)\n";
        echo "test 4 _b: " . self::_b . " (epxect 0)\n";

        int a = 0;
        int b = 1;
        let a += 1;
        let b += 1;
        echo "test 5 a: " . a . " (epxect 1)\n";
        echo "test 5 b: " . b . " (epxect 2)\n";

        let a = 0;
        let b = 1;
        let a -= 1;
        let b -= 1;
        echo "test 6 a: " . a . " (epxect -1)\n";
        echo "test 6 b: " . b . " (epxect 0)\n";

        let a = 0;
        let b = 1;
        let a = a + 1;
        let b = b + 1;
        echo "test 7 a: " . a . " (epxect 1)\n";
        echo "test 7 b: " . b . " (epxect 2)\n";

        let a = 0;
        let b = 1;
        let a = a - 1;
        let b = b - 1;
        echo "test 8 a: " . a . " (epxect -1)\n";
        echo "test 8 b: " . b . " (epxect 0)\n";
    }
}

@dreamsxin dreamsxin mentioned this issue Dec 31, 2019
3 tasks
@sergeyklay
Copy link
Contributor

Fixed in the development branch. Feel free to open a new issue if the problem appears again. Thank you for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants