Skip to content

Commit 4825926

Browse files
committed
Removed type restrictions from CompoundType
1 parent 03309cb commit 4825926

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/type/CompoundType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function buildFromTypes(array $types): Type {
5050
}
5151
}
5252
if(count($uniqueTypes) === 1) {
53-
return $uniqueTypes[0];
53+
return $uniqueTypes[0]->setRestrictedValues(null);
5454
} else {
5555
return new CompoundType($uniqueTypes);
5656
}

test/type/CompoundTypeTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ public function testTruthy(): void {
1818
$formula = new Formula('var a = func(); a = 0; return a;', $scope);
1919
$this->assertEquals(0, $formula->calculate()->toPHPValue());
2020
}
21+
22+
public function testNoValueRestrictions(): void {
23+
$formula = new Formula('true ? 1 : 2');
24+
$this->assertNull($formula->getReturnType()->getRestrictedValues());
25+
}
2126
}

0 commit comments

Comments
 (0)