Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14399312
D14271.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D14271.diff
View Options
diff --git a/src/parser/PhutilTypeSpec.php b/src/parser/PhutilTypeSpec.php
--- a/src/parser/PhutilTypeSpec.php
+++ b/src/parser/PhutilTypeSpec.php
@@ -172,6 +172,15 @@
}
public static function getCommonParentClass($class_a, $class_b) {
+ // Make sure both classes are really classes.
+ try {
+ if (!class_exists($class_a) || !class_exists($class_b)) {
+ return null;
+ }
+ } catch (PhutilMissingSymbolException $ex) {
+ return null;
+ }
+
$ancestors_a = array();
do {
$ancestors_a[] = $class_a;
diff --git a/src/parser/__tests__/PhutilTypeSpecTestCase.php b/src/parser/__tests__/PhutilTypeSpecTestCase.php
--- a/src/parser/__tests__/PhutilTypeSpecTestCase.php
+++ b/src/parser/__tests__/PhutilTypeSpecTestCase.php
@@ -170,7 +170,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeCheckException);
+ $this->assertTrue($caught instanceof PhutilTypeCheckException);
}
}
@@ -208,7 +208,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeMissingParametersException);
+ $this->assertTrue($caught instanceof PhutilTypeMissingParametersException);
// Parameter "size" is specified but does not exist.
@@ -224,7 +224,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeExtraParametersException);
+ $this->assertTrue($caught instanceof PhutilTypeExtraParametersException);
}
public function testRegexValidation() {
@@ -249,7 +249,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeCheckException);
+ $this->assertTrue($caught instanceof PhutilTypeCheckException);
}
public function testScalarOrListRegexp() {
@@ -288,4 +288,25 @@
$this->assertTrue(true);
}
+ public function testMixedVector() {
+ // This is a test case for an issue where we would not infer the type
+ // of a vector containing a mixture of scalar and nonscalar elements
+ // correctly.
+
+ $caught = null;
+ try {
+ PhutilTypeSpec::checkMap(
+ array(
+ 'key' => array('!', (object)array()),
+ ),
+ array(
+ 'key' => 'list<X>',
+ ));
+ } catch (PhutilTypeCheckException $ex) {
+ $caught = $ex;
+ }
+
+ $this->assertTrue($caught instanceof PhutilTypeCheckException);
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 4:33 PM (18 h, 57 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921591
Default Alt Text
D14271.diff (2 KB)
Attached To
Mode
D14271: Fix an issue where we infer the wrong type of a vector which mixes scalar types
Attached
Detach File
Event Timeline
Log In to Comment