Skip to content

Commit 454783a

Browse files
authored
Merge pull request #2626 from zephir-lang/#1629-fix-char
#1629 - Fix `char` values in dynamic contexts
2 parents 20b60a9 + e17afe5 commit 454783a

76 files changed

Lines changed: 5075 additions & 292 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
1717
- Added a `--with-php-config=PATH` option to the `build`, `compile` and `fullclean` commands, so an extension can be built against a PHP installation other than the one in the `PATH` (e.g. a separate ZTS build). `phpize` is taken from the same directory as the given `php-config`, and an unusable or mismatched path is rejected before the build starts. Not available on Windows, where the dev-pack (`%PHP_DEVPACK%`) selects the target PHP [#1834](https://github.com/zephir-lang/zephir/issues/1834)
1818

1919
### Fixed
20+
- Fixed `char`/`uchar` values in dynamic (zval) contexts. A string offset read (`s[i]`) now boxes as a 1-character string when its target is a `var`/`string` variable or an array element, matching PHP's `$s[$i]`: `string ch; let ch = s[i];` used to emit C that did not compile, and `let pieces[] = s[i];` was rejected with `Unknown type: uchar`. A declared `char`/`uchar` variable still boxes as its integer byte value (as `let a = [ch]` and `return ch` already did) — use `(string) ch` for the character — and a direct `return s[i]` is unchanged [#1629](https://github.com/zephir-lang/zephir/issues/1629)
21+
- `char`/`uchar` are now accepted in the remaining scalar positions, each of which previously threw or emitted invalid C: `(uchar)` casts, `(string)`/`(char)` casts of a `uchar`, `uchar` method parameters and globals, keyed array literals (`[1: ch]`), `let a[k] = ch`, object and static property array offsets, and `double`/`bool` targets. A `char` literal reaching a numeric slot no longer emits `ZVAL_LONG(&x, ''a'')`, and assigning an `int` to a `string` (`string s; let s = i;`) no longer emits dead PHP-5 code [#1629](https://github.com/zephir-lang/zephir/issues/1629)
2022
- Fixed `acos()` and `asin()` never using their optimizers on case-sensitive filesystems: optimizer lookup derives `AcosOptimizer.php`/`AsinOptimizer.php` from the function name, but the files were named `ACosOptimizer.php`/`ASinOptimizer.php`, so both calls compiled to a runtime function call on Linux while macOS and Windows inlined them [#2468](https://github.com/zephir-lang/zephir/issues/2468)
2123
- Fixed typed-property and array-class-constant string defaults containing escape sequences (e.g. `protected string x = "A\\B\\C"`) being emitted with the wrong byte length: the length was `strlen()` of the source-escaped PHP value (a `\\` counted as two bytes) while the C string literal is shorter, so the runtime string was over-long and corrupted with trailing garbage bytes. The length is now measured by the C compiler (`SL()` / `sizeof`), correct for every escape sequence [#2617](https://github.com/zephir-lang/zephir/issues/2617)
2224
- Fixed the `Zephir version has changed` warning firing on every rebuild: the version-cache directory existence check used `is_file()` on a path that is always a directory, so the check never matched and the warning degraded to "warn whenever the project was already built". It now fires only on a genuine version change and names the old and new versions [#2621](https://github.com/zephir-lang/zephir/issues/2621)

ext/config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ if test "$PHP_STUB" = "yes"; then
117117
stub/issue1404.zep.c
118118
stub/issue1521.zep.c
119119
stub/issue1628.zep.c
120+
stub/issue1629.zep.c
120121
stub/issue1706.zep.c
121122
stub/issue1790.zep.c
122123
stub/issue2030.zep.c

ext/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (PHP_STUB != "no") {
1111
}
1212

1313
ADD_SOURCES(configure_module_dirname + "/stub/invokes", "abstractprotected.zep.c abstractinvoker.zep.c abstractinvokercomplex.zep.c invokeprotected.zep.c invokeprotectedcomplex.zep.c", "stub");
14-
ADD_SOURCES(configure_module_dirname + "/stub", "testinterface.zep.c scallparent.zep.c constantsparent.zep.c issue1628abstract.zep.c issue2324.zep.c issue2505.zep.c issue2537.zep.c methodinterface.zep.c propertycache.zep.c arithmetic.zep.c arrayaccessarr.zep.c arrayaccessobj.zep.c arrayaccessproperty.zep.c arrayaccesstest.zep.c arrayiterator.zep.c arrayiteratortest.zep.c arraymanipulation.zep.c arrayobject.zep.c arraysearch.zep.c assign.zep.c bench.zep.c bitwise.zep.c branchprediction.zep.c cast.zep.c cblock.zep.c chars.zep.c closures.zep.c compare.zep.c concat.zep.c constantparameterdefault.zep.c constants.zep.c constantsinterface.zep.c constantsinterfacea.zep.c constantsinterfaceb.zep.c declaretest.zep.c diinterface.zep.c echoes.zep.c emptytest.zep.c evaltest.zep.c exception.zep.c exceptions.zep.c exists.zep.c exitdie.zep.c extendedinterface.zep.c factorial.zep.c fannkuch.zep.c fasta.zep.c fcall.zep.c fetchtest.zep.c fibonnaci.zep.c flow.zep.c fortytwo.zep.c functional.zep.c functionexists.zep.c functions.zep.c generators.zep.c geometry.zep.c globals.zep.c instance.zep.c instanceoff.zep.c internalclasses.zep.c internalinterfaces.zep.c invoke.zep.c issettest.zep.c issue1097.zep.c issue1134.zep.c issue1404.zep.c issue1521.zep.c issue1628.zep.c issue1706.zep.c issue1790.zep.c issue2030.zep.c issue2063.zep.c issue2167.zep.c issue2324extended.zep.c issue2385.zep.c issue2394.zep.c issue2409.zep.c issue2428.zep.c issue2469.zep.c issue2505crosschain.zep.c issue2505extended.zep.c issue2522.zep.c issue2533.zep.c issue2537child.zep.c issue2542.zep.c issue2543.zep.c issue2546.zep.c issue2564.zep.c issue2564padfactory.zep.c issue2565.zep.c issue663.zep.c issue808.zep.c issue820.zep.c issue882.zep.c issue887.zep.c issue893.zep.c issue914.zep.c issues.zep.c json.zep.c logical.zep.c mcall.zep.c mcallchained.zep.c mcalldynamic.zep.c mcallinternal.zep.c methodabstract.zep.c methodargs.zep.c methodswithdefaultvalues.zep.c multidimarray.zep.c nativearray.zep.c oo.zep.c openssl.zep.c operator.zep.c pdostatement.zep.c pregmatch.zep.c propertycachechild.zep.c propertycachemagic.zep.c quantum.zep.c range.zep.c references.zep.c reflection.zep.c regexdna.zep.c requires.zep.c resourcetest.zep.c returns.zep.c router.zep.c scall.zep.c scalldynamic.zep.c scallexternal.zep.c scalllateconstruct.zep.c scope.zep.c sort.zep.c spectralnorm.zep.c spl.zep.c spropertyaccess.zep.c statements.zep.c strings.zep.c stubs.zep.c ternary.zep.c trytest.zep.c typeinstances.zep.c typeoff.zep.c unknownclass.zep.c unreachableloop.zep.c unsettest.zep.c unspacedminus.zep.c usetest.zep.c variadic.zep.c vars.zep.c 0__closure.zep.c 1__closure.zep.c 2__closure.zep.c 3__closure.zep.c 4__closure.zep.c 5__closure.zep.c 6__closure.zep.c 7__closure.zep.c 8__closure.zep.c 9__closure.zep.c 10__closure.zep.c 11__closure.zep.c 12__closure.zep.c 13__closure.zep.c 14__closure.zep.c 15__closure.zep.c 16__closure.zep.c 17__closure.zep.c 18__closure.zep.c 19__closure.zep.c 20__closure.zep.c 21__closure.zep.c 22__closure.zep.c 23__closure.zep.c 24__closure.zep.c 25__closure.zep.c 26__closure.zep.c 27__closure.zep.c 28__closure.zep.c 29__closure.zep.c 30__closure.zep.c", "stub");
14+
ADD_SOURCES(configure_module_dirname + "/stub", "testinterface.zep.c scallparent.zep.c constantsparent.zep.c issue1628abstract.zep.c issue2324.zep.c issue2505.zep.c issue2537.zep.c methodinterface.zep.c propertycache.zep.c arithmetic.zep.c arrayaccessarr.zep.c arrayaccessobj.zep.c arrayaccessproperty.zep.c arrayaccesstest.zep.c arrayiterator.zep.c arrayiteratortest.zep.c arraymanipulation.zep.c arrayobject.zep.c arraysearch.zep.c assign.zep.c bench.zep.c bitwise.zep.c branchprediction.zep.c cast.zep.c cblock.zep.c chars.zep.c closures.zep.c compare.zep.c concat.zep.c constantparameterdefault.zep.c constants.zep.c constantsinterface.zep.c constantsinterfacea.zep.c constantsinterfaceb.zep.c declaretest.zep.c diinterface.zep.c echoes.zep.c emptytest.zep.c evaltest.zep.c exception.zep.c exceptions.zep.c exists.zep.c exitdie.zep.c extendedinterface.zep.c factorial.zep.c fannkuch.zep.c fasta.zep.c fcall.zep.c fetchtest.zep.c fibonnaci.zep.c flow.zep.c fortytwo.zep.c functional.zep.c functionexists.zep.c functions.zep.c generators.zep.c geometry.zep.c globals.zep.c instance.zep.c instanceoff.zep.c internalclasses.zep.c internalinterfaces.zep.c invoke.zep.c issettest.zep.c issue1097.zep.c issue1134.zep.c issue1404.zep.c issue1521.zep.c issue1628.zep.c issue1629.zep.c issue1706.zep.c issue1790.zep.c issue2030.zep.c issue2063.zep.c issue2167.zep.c issue2324extended.zep.c issue2385.zep.c issue2394.zep.c issue2409.zep.c issue2428.zep.c issue2469.zep.c issue2505crosschain.zep.c issue2505extended.zep.c issue2522.zep.c issue2533.zep.c issue2537child.zep.c issue2542.zep.c issue2543.zep.c issue2546.zep.c issue2564.zep.c issue2564padfactory.zep.c issue2565.zep.c issue663.zep.c issue808.zep.c issue820.zep.c issue882.zep.c issue887.zep.c issue893.zep.c issue914.zep.c issues.zep.c json.zep.c logical.zep.c mcall.zep.c mcallchained.zep.c mcalldynamic.zep.c mcallinternal.zep.c methodabstract.zep.c methodargs.zep.c methodswithdefaultvalues.zep.c multidimarray.zep.c nativearray.zep.c oo.zep.c openssl.zep.c operator.zep.c pdostatement.zep.c pregmatch.zep.c propertycachechild.zep.c propertycachemagic.zep.c quantum.zep.c range.zep.c references.zep.c reflection.zep.c regexdna.zep.c requires.zep.c resourcetest.zep.c returns.zep.c router.zep.c scall.zep.c scalldynamic.zep.c scallexternal.zep.c scalllateconstruct.zep.c scope.zep.c sort.zep.c spectralnorm.zep.c spl.zep.c spropertyaccess.zep.c statements.zep.c strings.zep.c stubs.zep.c ternary.zep.c trytest.zep.c typeinstances.zep.c typeoff.zep.c unknownclass.zep.c unreachableloop.zep.c unsettest.zep.c unspacedminus.zep.c usetest.zep.c variadic.zep.c vars.zep.c 0__closure.zep.c 1__closure.zep.c 2__closure.zep.c 3__closure.zep.c 4__closure.zep.c 5__closure.zep.c 6__closure.zep.c 7__closure.zep.c 8__closure.zep.c 9__closure.zep.c 10__closure.zep.c 11__closure.zep.c 12__closure.zep.c 13__closure.zep.c 14__closure.zep.c 15__closure.zep.c 16__closure.zep.c 17__closure.zep.c 18__closure.zep.c 19__closure.zep.c 20__closure.zep.c 21__closure.zep.c 22__closure.zep.c 23__closure.zep.c 24__closure.zep.c 25__closure.zep.c 26__closure.zep.c 27__closure.zep.c 28__closure.zep.c 29__closure.zep.c 30__closure.zep.c", "stub");
1515
ADD_SOURCES(configure_module_dirname + "/stub/oo/extend", "exception.zep.c", "stub");
1616
ADD_SOURCES(configure_module_dirname + "/stub/issue2165", "issueextendinterface.zep.c issueinterface.zep.c issue.zep.c", "stub");
1717
ADD_SOURCES(configure_module_dirname + "/stub/oo/extend/db", "exception.zep.c", "stub");

ext/stub.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ zend_class_entry *stub_issue1134_ce;
165165
zend_class_entry *stub_issue1404_ce;
166166
zend_class_entry *stub_issue1521_ce;
167167
zend_class_entry *stub_issue1628_ce;
168+
zend_class_entry *stub_issue1629_ce;
168169
zend_class_entry *stub_issue1706_ce;
169170
zend_class_entry *stub_issue1790_ce;
170171
zend_class_entry *stub_issue2030_ce;
@@ -451,6 +452,7 @@ static PHP_MINIT_FUNCTION(stub)
451452
ZEPHIR_INIT(Stub_Issue1404);
452453
ZEPHIR_INIT(Stub_Issue1521);
453454
ZEPHIR_INIT(Stub_Issue1628);
455+
ZEPHIR_INIT(Stub_Issue1629);
454456
ZEPHIR_INIT(Stub_Issue1706);
455457
ZEPHIR_INIT(Stub_Issue1790);
456458
ZEPHIR_INIT(Stub_Issue2030);
@@ -694,6 +696,7 @@ static void php_zephir_init_module_globals(zend_stub_globals *stub_globals)
694696

695697
}
696698

699+
void zephir_init_static_properties_Stub_Issue1629();
697700
void zephir_init_static_properties_Stub_Properties_StaticPropertyArray();
698701
void zephir_init_static_properties_Stub_SPropertyAccess();
699702
static PHP_RINIT_FUNCTION(stub)
@@ -704,6 +707,7 @@ static PHP_RINIT_FUNCTION(stub)
704707
php_zephir_init_globals(stub_globals_ptr);
705708
zephir_initialize_memory(stub_globals_ptr);
706709

710+
zephir_init_static_properties_Stub_Issue1629();
707711
zephir_init_static_properties_Stub_Properties_StaticPropertyArray();
708712
zephir_init_static_properties_Stub_SPropertyAccess();
709713

ext/stub.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#include "stub/issue1404.zep.h"
113113
#include "stub/issue1521.zep.h"
114114
#include "stub/issue1628.zep.h"
115+
#include "stub/issue1629.zep.h"
115116
#include "stub/issue1706.zep.h"
116117
#include "stub/issue1790.zep.h"
117118
#include "stub/issue2030.zep.h"

ext/stub/16__closure.zep.c

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/stub/17__closure.zep.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/stub/18__closure.zep.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/stub/cast.zep.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)