Skip to content

Commit c36e7d4

Browse files
committed
Fix promoted argument types not being recorded
1 parent e2b6078 commit c36e7d4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ XP Compiler ChangeLog
33

44
## ?.?.? / ????-??-??
55

6+
## 0.9.1 / 2017-10-21
7+
8+
* Fixed promoted argument types not being recorded - @thekid
9+
610
## 0.9.0 / 2017-10-21
711

812
* Added support for `$arg ==> $arg++` lambdas without argument braces

src/main/php/lang/ast/Emitter.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ protected function emitMethod($node) {
392392
$declare= $promote= $params= '';
393393
foreach ($node->value[2][0] as $param) {
394394
if (isset($param[4])) {
395-
$declare= $param[4].' $'.$param[0].';';
395+
$declare.= $param[4].' $'.$param[0].';';
396396
$promote.= '$this->'.$param[0].'= $'.$param[0].';';
397397
$this->meta[0][self::PROPERTY][$param[0]]= [
398398
DETAIL_RETURNS => $param[2] ? $param[2]->name() : 'var',

src/test/php/lang/ast/unittest/emit/ArgumentPromotionTest.class.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ public function run() {
5757
#[@test]
5858
public function type_information() {
5959
$t= $this->type('class <T> {
60-
public function __construct(private int $id) {
60+
public function __construct(private int $id, private string $name) {
6161
}
6262
}');
63-
$this->assertEquals(Primitive::$INT, $t->getField('id')->getType());
63+
$this->assertEquals(
64+
[Primitive::$INT, Primitive::$STRING],
65+
[$t->getField('id')->getType(), $t->getField('name')->getType()]
66+
);
6467
}
6568
}

0 commit comments

Comments
 (0)