Skip to content

Commit 88d23e6

Browse files
committed
Validate constants
1 parent f817838 commit 88d23e6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build/gen_stub.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,14 @@ public function getDeclaration(iterable $allConstInfos): string
18471847
}
18481848

18491849
$value = EvaluatedValue::createFromExpression($this->value, $type, $this->cname, $allConstInfos);
1850+
if (!$value->isUnknownConstValue && !$value->originatingConst) {
1851+
throw new Exception("Constant " . $this->name->__toString() . " must have either UNKNOWN or a constant value");
1852+
}
1853+
1854+
$value = EvaluatedValue::createFromExpression($this->value, $type, $this->cname, $allConstInfos);
1855+
if ($value->isUnknownConstValue && !$value->cConstName) {
1856+
throw new Exception("Constant " . $this->name->__toString() . " must have a @cname annotation");
1857+
}
18501858

18511859
$code = "";
18521860

0 commit comments

Comments
 (0)