File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
src/System.Management.Automation/engine/parser
test/powershell/engine/Api Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -936,6 +936,11 @@ object ICustomAstVisitor.VisitContinueStatement(ContinueStatementAst continueSta
936
936
937
937
object ICustomAstVisitor . VisitReturnStatement ( ReturnStatementAst returnStatementAst )
938
938
{
939
+ if ( returnStatementAst . Pipeline is null )
940
+ {
941
+ return TypeInferenceContext . EmptyPSTypeNameArray ;
942
+ }
943
+
939
944
return returnStatementAst . Pipeline . Accept ( this ) ;
940
945
}
941
946
Original file line number Diff line number Diff line change @@ -796,6 +796,11 @@ Describe "Type inference Tests" -tags "CI" {
796
796
$res.Name | Should - Be ' System.Int32'
797
797
}
798
798
799
+ It ' Infers type from empty Return statement' {
800
+ $res = [AstTypeInference ]::InferTypeOf( { return }.Ast)
801
+ $res.Count | Should - Be 0
802
+ }
803
+
799
804
It ' Infers type from New-Object statement' {
800
805
$res = [AstTypeInference ]::InferTypeOf( {
801
806
New-Object - TypeName ' System.Diagnostics.Stopwatch'
You can’t perform that action at this time.
0 commit comments