php-zephir-parser icon indicating copy to clipboard operation
php-zephir-parser copied to clipboard

Compilation error on accessing dynamic properties

Open sergeyklay opened this issue 8 years ago • 2 comments

From @SliceOfLife on December 14, 2014 12:54

The documentation says, that I can use a variable value as property name:

let someProperty = "myProperty";
let this->{someProperty} = 100;

But I can't use variable to access a property of class in array:

    public static function doSomething()
    {
        var _array, property;

        let _array = [];
        let _array["index"] = new stdClass();
        let property = "test";
        let _array["index"]->{property} = 1;
    }

Compiler throws an exception:

Zephir\ParseException: Syntax error in .../TestClass.zep on line 13

      let _array["index"]->{property} = 1;
    ----------------------^

Zephir version 0.5.9a [396cb30]

Copied from original issue: phalcon/zephir#684

sergeyklay avatar May 13 '17 10:05 sergeyklay

From @steffengy on December 14, 2014 14:54

Probably related to some limitations like here: https://github.com/phalcon/zephir/issues/573

sergeyklay avatar May 13 '17 10:05 sergeyklay

From @SliceOfLife on December 14, 2014 15:8

Yes, you are right.

sergeyklay avatar May 13 '17 10:05 sergeyklay