1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Be more accurate when assertion is incorrect

Ref #2452
This commit is contained in:
Matthew Brown 2019-12-10 09:26:46 -05:00
parent 8494f02008
commit 750d4b4f4f
2 changed files with 33 additions and 8 deletions

View File

@ -1041,7 +1041,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1100,7 +1102,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1155,7 +1159,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1220,7 +1226,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1283,7 +1291,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1517,7 +1527,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1591,7 +1603,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**
@ -1681,7 +1695,9 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$failed_reconciliation = 2;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getEmpty();
}
/**

View File

@ -2213,6 +2213,15 @@ class ConditionalTest extends \Psalm\Tests\TestCase
}
}'
],
'ignoreRedundantAssertion' => [
'<?php
function gimmeAString(?string $v): string {
/** @psalm-suppress TypeDoesNotContainType */
assert(is_string($v) || is_object($v));
return $v;
}'
],
];
}