Skip to content

Commit ff2e3a6

Browse files
committed
Test failure when updating class constants
1 parent cedd3ea commit ff2e3a6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test failure of updating class constants
3+
--FILE--
4+
<?php
5+
6+
enum Foo: string {
7+
const Bar = NONEXISTENT;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: During updating of class constants: Uncaught Error: Undefined constant "NONEXISTENT" in %s:%d
13+
Stack trace:
14+
#0 {main} in %s on line %d

Zend/zend_enum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "zend_enum_arginfo.h"
2323
#include "zend_interfaces.h"
2424
#include "zend_enum.h"
25+
#include "zend_exceptions.h"
2526

2627
#define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName) \
2728
do { \
@@ -190,8 +191,7 @@ void zend_enum_build_backed_enum_table(zend_class_entry *ce)
190191
ZEND_ASSERT(backing_type != IS_UNDEF);
191192

192193
if (zend_update_class_constants(ce) == FAILURE) {
193-
// FIXME: What's the right way to error here?
194-
zend_error_noreturn(E_COMPILE_ERROR, "Could not update class constants");
194+
zend_exception_uncaught_error("During updating of class constants");
195195
}
196196

197197
ce->backed_enum_table = emalloc(sizeof(HashTable));

0 commit comments

Comments
 (0)