mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #5540 - function is used inside throw expression
This commit is contained in:
parent
59b7de5647
commit
150dd00060
@ -1008,11 +1008,12 @@ class FunctionCallAnalyzer extends CallAnalyzer
|
||||
* If a function is pure, and has the return type of 'no-return',
|
||||
* it's okay to dismiss it's return value.
|
||||
*/
|
||||
if (!$context->inside_assignment &&
|
||||
!$context->inside_call &&
|
||||
!$context->inside_use &&
|
||||
!self::callUsesByReferenceArguments($function_call_info, $stmt) &&
|
||||
!(
|
||||
if (!$context->inside_assignment
|
||||
&& !$context->inside_call
|
||||
&& !$context->inside_use
|
||||
&& !$context->inside_throw
|
||||
&& !self::callUsesByReferenceArguments($function_call_info, $stmt)
|
||||
&& !(
|
||||
$function_call_info->function_storage &&
|
||||
$function_call_info->function_storage->return_type &&
|
||||
$function_call_info->function_storage->return_type->isNever()
|
||||
|
@ -892,7 +892,19 @@ class UnusedCodeTest extends TestCase
|
||||
|
||||
return $f;
|
||||
}',
|
||||
]
|
||||
],
|
||||
'functionCallUsedInThrow' => [
|
||||
'<?php
|
||||
/**
|
||||
* @psalm-pure
|
||||
*/
|
||||
function getException(): \Exception
|
||||
{
|
||||
return new \Exception();
|
||||
}
|
||||
|
||||
throw getException();'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user