Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0ac57d5
Make zend_type a 2-field struct
nikic Sep 20, 2019
8b62d66
Store pass_by_reference+is_variadic in type mask
nikic Sep 24, 2019
4a9735f
WIP Union types
nikic Sep 25, 2019
8f9c57f
Fetch unresolved classes from autoload table
nikic Oct 18, 2019
9c58da4
Fix coercion error
nikic Oct 18, 2019
48e3379
Remove special exceptions when failing to resolve prop type class
nikic Oct 18, 2019
82cfa0c
Fix the typed reference assignment logic
nikic Oct 18, 2019
c786f78
Make loading in type errors robust
nikic Oct 18, 2019
67c0d29
Add tests for redundant types
nikic Oct 18, 2019
af73a41
Tweak error messages
nikic Oct 18, 2019
4a8d0af
Handle iterable + Traversable
nikic Oct 18, 2019
471c27f
Move test files
nikic Oct 18, 2019
f681fb6
More tests
nikic Oct 18, 2019
20495e1
Check for standalone null/false
nikic Oct 18, 2019
291f52c
Use smart_str for type error
nikic Oct 18, 2019
b49438b
Proper type error for union types
nikic Oct 18, 2019
887656d
Fix weak typing logic
nikic Oct 18, 2019
24f863a
Cleanup MAY_BE_BOOL
nikic Oct 18, 2019
37b3997
Add weak typing tests
nikic Oct 18, 2019
ccf57e9
Support union types in AST printer
nikic Oct 18, 2019
c1152c9
Add strict type variant of test
nikic Oct 21, 2019
7fc7982
Implement correct incdec handling
nikic Oct 21, 2019
209f7f1
Test property references
nikic Oct 21, 2019
5213df3
Implement full property invariance check
nikic Oct 21, 2019
9e50dfe
Add ReflectionUnionType
nikic Oct 21, 2019
b0f545c
Add a class loading test
nikic Oct 21, 2019
824ed44
Remove unused variable
nikic Oct 21, 2019
f1d05a4
Try to fix ZTS build (untested)
nikic Oct 21, 2019
fad9419
Allocate property type lists on arena
nikic Oct 22, 2019
686e61f
Remove duplicate test
nikic Oct 23, 2019
e0e204d
Add test for void + class
nikic Oct 23, 2019
476adfa
Run coverage job
nikic Oct 23, 2019
e7aecad
Adjust test after property type loading changes
nikic Oct 23, 2019
716cd38
Add test for generator with multiple class return types
nikic Oct 23, 2019
7e7d240
Add test for iterable+Traversable redundancy with extra class
nikic Oct 23, 2019
6abe540
Add inheritance test and fix some related issues
nikic Oct 23, 2019
59802bb
Fixup reflection after rebase
nikic Nov 7, 2019
f85a717
Revert "Run coverage job"
nikic Nov 8, 2019
c06e6c9
Add json skipifs
nikic Nov 8, 2019
956d3a3
Extra variance test
nikic Nov 8, 2019
8bb01a8
Fix issues related to inheritance of internal union types
nikic Nov 8, 2019
3a9ff5d
Properly destroy internal property types
nikic Nov 8, 2019
edcd6d9
Fix missing cache slot increment
nikic Nov 8, 2019
b036ffa
Use goto for common code-paths
nikic Nov 8, 2019
ccbd868
Add test for iterable variance
nikic Nov 8, 2019
54f9bd4
Fix accidental whitespace change
nikic Nov 8, 2019
c443f3b
Apply cache slot fix to jit as well
nikic Nov 8, 2019
b1615d1
Fix file cache
nikic Nov 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweak error messages
  • Loading branch information
nikic committed Nov 7, 2019
commit af73a41954b3a53c79ca64388f10660336291135
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ function test(): bool|false {

?>
--EXPECTF--
Fatal error: Type bool is redundant in %s on line %d
Fatal error: Duplicate type false is redundant in %s on line %d
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ function test(): Foo|int|FOO {

?>
--EXPECTF--
Fatal error: Type FOO is redundant in %s on line %d
Fatal error: Duplicate type FOO is redundant in %s on line %d
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ function test(): int|INT {

?>
--EXPECTF--
Fatal error: Type int is redundant in %s on line %d
Fatal error: Duplicate type int is redundant in %s on line %d
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ function test(): iterable|array {
}

?>
--EXPECT--
TODO
--EXPECTF--
Fatal error: Type iterable|array contains both iterable and array, which is redundant in %s on line %d
14 changes: 10 additions & 4 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ static zend_string *add_type_string(zend_string *type, zend_string *new_type) {
result = zend_string_alloc(ZSTR_LEN(type) + ZSTR_LEN(new_type) + 1, 0);
memcpy(ZSTR_VAL(result), ZSTR_VAL(type), ZSTR_LEN(type));
ZSTR_VAL(result)[ZSTR_LEN(type)] = '|';
memcpy(ZSTR_VAL(result) + ZSTR_LEN(type), ZSTR_VAL(new_type), ZSTR_LEN(new_type));
memcpy(ZSTR_VAL(result) + ZSTR_LEN(type) + 1, ZSTR_VAL(new_type), ZSTR_LEN(new_type));
ZSTR_VAL(result)[ZSTR_LEN(type) + ZSTR_LEN(new_type) + 1] = '\0';
zend_string_release(type);
return result;
Expand Down Expand Up @@ -5503,11 +5503,10 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
uint32_t type_mask_overlap =
ZEND_TYPE_PURE_MASK(type) & ZEND_TYPE_PURE_MASK(single_type);
if (type_mask_overlap) {
// TODO: Iterable requires special handling
zend_type overlap_type = ZEND_TYPE_INIT_MASK(type_mask_overlap);
zend_string *overlap_type_str = zend_type_to_string(overlap_type);
zend_error_noreturn(E_COMPILE_ERROR,
"Type %s is redundant", ZSTR_VAL(overlap_type_str));
"Duplicate type %s is redundant", ZSTR_VAL(overlap_type_str));
}
ZEND_TYPE_FULL_MASK(type) |= ZEND_TYPE_PURE_MASK(single_type);

Expand Down Expand Up @@ -5539,7 +5538,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
ZEND_TYPE_NAME(single_type))) {
zend_string *single_type_str = zend_type_to_string(single_type);
zend_error_noreturn(E_COMPILE_ERROR,
"Type %s is redundant", ZSTR_VAL(single_type_str));
"Duplicate type %s is redundant", ZSTR_VAL(single_type_str));
}
}
}
Expand All @@ -5553,6 +5552,13 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
ZEND_TYPE_FULL_MASK(type) |= MAY_BE_NULL;
}

if ((ZEND_TYPE_FULL_MASK(type) & (MAY_BE_ARRAY|MAY_BE_ITERABLE))
== (MAY_BE_ARRAY|MAY_BE_ITERABLE)) {
zend_string *type_str = zend_type_to_string(type);
zend_error_noreturn(E_COMPILE_ERROR,
"Type %s contains both iterable and array, which is redundant", ZSTR_VAL(type_str));
}

if ((ZEND_TYPE_FULL_MASK(type) & MAY_BE_OBJECT) && ZEND_TYPE_HAS_CLASS(type)) {
zend_string *type_str = zend_type_to_string(type);
zend_error_noreturn(E_COMPILE_ERROR,
Expand Down