File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1948,12 +1948,12 @@ export class Compiler extends DiagnosticEmitter {
19481948 var module = this . module ;
19491949 var expr : ExpressionRef = 0 ;
19501950 var flow = this . currentFlow ;
1951+ var returnType = flow . returnType ;
19511952
19521953 // Remember that this flow returns
19531954 flow . set ( FlowFlags . RETURNS ) ;
19541955
19551956 if ( statement . value ) {
1956- let returnType = flow . returnType ;
19571957 if ( returnType == Type . void ) {
19581958 this . compileExpressionRetainType ( statement . value , returnType , WrapMode . NONE ) ;
19591959 this . error (
@@ -1974,6 +1974,13 @@ export class Compiler extends DiagnosticEmitter {
19741974
19751975 // Remember whether returning a properly wrapped value
19761976 if ( ! flow . canOverflow ( expr , returnType ) ) flow . set ( FlowFlags . RETURNS_WRAPPED ) ;
1977+
1978+ } else if ( returnType != Type . void ) {
1979+ this . error (
1980+ DiagnosticCode . Type_0_is_not_assignable_to_type_1 ,
1981+ statement . range , "void" , returnType . toString ( )
1982+ ) ;
1983+ expr = module . createUnreachable ( ) ;
19771984 }
19781985
19791986 // If the last statement anyway, make it the block's return value
You can’t perform that action at this time.
0 commit comments