From a2fe8d48b13df62d3363d448b3d0e2752b10daf9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 5 Nov 2021 17:05:55 +0100 Subject: [PATCH] Partially address bug #78647 Produce a sensible error message for the case where inheritance should fail. There is still a remaining issue that we sometimes fail inheritance while we should not. --- .../variance/class_order_autoload_error7.phpt | 24 +++++++++++++++++++ Zend/zend_inheritance.c | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/type_declarations/variance/class_order_autoload_error7.phpt diff --git a/Zend/tests/type_declarations/variance/class_order_autoload_error7.phpt b/Zend/tests/type_declarations/variance/class_order_autoload_error7.phpt new file mode 100644 index 00000000000..c4b4cc05ee7 --- /dev/null +++ b/Zend/tests/type_declarations/variance/class_order_autoload_error7.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #78647: Outstanding dependency obligation +--FILE-- + +--EXPECTF-- +Fatal error: Could not check compatibility between B::m(): X and A::m(): B, because class X is not available in %s on line %d diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index b30bb523d36..57314d78448 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -2548,7 +2548,8 @@ static void report_variance_errors(zend_class_entry *ce) { } else if (obligation->type == OBLIGATION_PROPERTY_COMPATIBILITY) { emit_incompatible_property_error(obligation->child_prop, obligation->parent_prop); } else { - zend_error_noreturn(E_CORE_ERROR, "Bug #78647"); + /* Report variance errors of the dependency, which prevent it from being linked. */ + report_variance_errors(obligation->dependency_ce); } } ZEND_HASH_FOREACH_END();