zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP

Home Page:https://zephir-lang.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`string` variable ending up with `null`

niden opened this issue · comments

    protected final function getSpecial(int special) -> string
    {
        string suffix = "";

        switch special {
            case 1:
                let suffix = "alpha";
                break;
            case 2:
                let suffix = "beta";
                break;
            case 3:
                let suffix = "RC";
                break;
        }

        return suffix;
    }

The above returns null when special is other than 1, 2 or 3. If a default clause is added to the switch it makes no difference.

Also adding

let suffix = "";

has no effect.

If the variable is changed to var suffix then the code works (i.e. you get an empty string if special is 4)