zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
https://zephir-lang.com
MIT License
3.29k stars 466 forks source link

Bugs with Chars #1988

Open sergeyklay opened 4 years ago

sergeyklay commented 4 years ago

Failed to compile

char ch = 'A';
printf("The value of '%s' is %c", ch, (char)ch);
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c: In function ‘zim_Bug_Chars_sum’:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:151:31: note: in expansion of macro ‘Z_TYPE_P’
 #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
                               ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:49:14: note: in expansion of macro ‘zephir_get_intval’
  _0 = (char) zephir_get_intval(&chlower);
              ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:572:31: error: request for member ‘value’ in something not a structure or union
 #define Z_LVAL(zval)    (zval).value.lval
                               ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:573:28: note: in expansion of macro ‘Z_LVAL’
 #define Z_LVAL_P(zval_p)   Z_LVAL(*(zval_p))
                            ^~~~~~
./kernel/operators.h:151:56: note: in expansion of macro ‘Z_LVAL_P’
 #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
                                                        ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:49:14: note: in expansion of macro ‘zephir_get_intval’
  _0 = (char) zephir_get_intval(&chlower);
              ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:15:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:49:32: warning: passing argument 1 of ‘zephir_get_intval_ex’ from incompatible pointer type [-Wincompatible-pointer-types]
  _0 = (char) zephir_get_intval(&chlower);
                                ^~~~~~~~
./kernel/operators.h:151:91: note: in definition of macro ‘zephir_get_intval’
 #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
                                                                                           ^
./kernel/operators.h:108:39: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 long zephir_get_intval_ex(const zval *op);
                           ~~~~~~~~~~~~^~
make: *** [Makefile:238: bug/chars.lo] Error 1
make: *** Waiting for unfinished jobs....

Return array of

    public function extract()
    {
        char ch1, ch2;
        string name = "peter";

        let ch1 = name[0],
            ch2 = name[1];

        return [ch1, ch2, ch1];

    }

[ERROR] Unknown char


Cast to string

    public function extract()
    {
        char ch1, ch2;
        string name = "peter";

        let ch1 = name[0],
            ch2 = name[1];

        return [
            "sprintf": sprintf("%s%s%s%s", ch1, ch2, ch1, ch2),
            "cast": (string)ch1 . (string)ch2 . (string)ch1 . (string)ch2
        ];
    }
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c: In function ‘zim_Bug_Chars_extract’:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_6, &ch1);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_6, &ch1);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:105:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_6, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_7, &ch2);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_7, &ch2);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:106:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_7, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_8, &ch1);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_8, &ch1);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:107:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_8, &ch1);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:399:39: warning: passing argument 1 of ‘zval_get_type’ from incompatible pointer type [-Wincompatible-pointer-types]
 #define Z_TYPE(zval)    zval_get_type(&(zval))
                                       ^~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:400:28: note: in expansion of macro ‘Z_TYPE’
 #define Z_TYPE_P(zval_p)   Z_TYPE(*(zval_p))
                            ^~~~~~
./kernel/operators.h:209:7: note: in expansion of macro ‘Z_TYPE_P’
   if (Z_TYPE_P(right) == IS_STRING) { \
       ^~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:389:64: note: expected ‘const zval *’ {aka ‘const struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                                    ~~~~~~~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:402:36: error: request for member ‘u1’ in something not a structure or union
 #define Z_TYPE_FLAGS(zval)   (zval).u1.v.type_flags
                                    ^
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:532:32: note: in expansion of macro ‘Z_TYPE_FLAGS’
 #define Z_REFCOUNTED(zval)   ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
                                ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:533:33: note: in expansion of macro ‘Z_REFCOUNTED’
 #define Z_REFCOUNTED_P(zval_p)  Z_REFCOUNTED(*(zval_p))
                                 ^~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:866:6: note: in expansion of macro ‘Z_REFCOUNTED_P’
  if (Z_REFCOUNTED_P((pz))) {  \
      ^~~~~~~~~~~~~~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:29,
                 from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:25: warning: passing argument 1 of ‘zval_addref_p’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_9, &ch2);
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:857:41: note: in definition of macro ‘Z_ADDREF_P’
 #define Z_ADDREF_P(pz)    zval_addref_p(pz)
                                         ^~
./kernel/memory.h:107:2: note: in expansion of macro ‘Z_TRY_ADDREF_P’
  Z_TRY_ADDREF_P(v); \
  ^~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:890:56: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 static zend_always_inline uint32_t zval_addref_p(zval* pz) {
                                                  ~~~~~~^~
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend_types.h:921:21: warning: initialization of ‘const zval *’ {aka ‘const struct _zval_struct *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
   const zval *_z2 = (v);       \
                     ^
./kernel/memory.h:115:2: note: in expansion of macro ‘ZVAL_COPY_VALUE’
  ZVAL_COPY_VALUE(d, v);
  ^~~~~~~~~~~~~~~
./kernel/operators.h:210:4: note: in expansion of macro ‘ZEPHIR_CPY_WRT’
    ZEPHIR_CPY_WRT(left, right); \
    ^~~~~~~~~~~~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:17:
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:25: warning: passing argument 1 of ‘zend_make_printable_zval’ from incompatible pointer type [-Wincompatible-pointer-types]
  zephir_get_strval(&_9, &ch2);
                         ^~~~
./kernel/operators.h:28:78: note: in definition of macro ‘zephir_make_printable_zval’
 #define zephir_make_printable_zval(expr, expr_copy) zend_make_printable_zval(expr, expr_copy);
                                                                              ^~~~
/home/klay/work/zephir/issues/ext/bug/chars.zep.c:108:2: note: in expansion of macro ‘zephir_get_strval’
  zephir_get_strval(&_9, &ch2);
  ^~~~~~~~~~~~~~~~~
In file included from /home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/main/php.h:35,
                 from /home/klay/work/zephir/issues/ext/bug/chars.zep.c:6:
/home/klay/.phpenv/versions/7.2.20-zts-debug/include/php/Zend/zend.h:236:45: note: expected ‘zval *’ {aka ‘struct _zval_struct *’} but argument is of type ‘char *’
 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
                                       ~~~~~~^~~~
make: *** [Makefile:238: bug/chars.lo] Error 1
make: *** Waiting for unfinished jobs....

Strange chr result

    public function extract()
    {
        char ch1, ch2;
        string name = "peter";

        let ch1 = name[0],
            ch2 = name[1];

        return [
            "sprintf": sprintf("%s%s%s%s", ch1, ch2, ch1, ch2),
            "cast": chr(ch1) . chr(ch2) . chr(ch1) . chr(ch2)
        ];
    }
$t = new Bug\Chars;
var_dump($t->extract());
array(2) {
  ["sprintf"]=>
  string(4) "pepe"
  ["cast"]=>
  string(4) ""
}
sergeyklay commented 4 years ago

Casting was fixed in https://github.com/phalcon/zephir/pull/1992