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 {
1948
1948
var module = this . module ;
1949
1949
var expr : ExpressionRef = 0 ;
1950
1950
var flow = this . currentFlow ;
1951
+ var returnType = flow . returnType ;
1951
1952
1952
1953
// Remember that this flow returns
1953
1954
flow . set ( FlowFlags . RETURNS ) ;
1954
1955
1955
1956
if ( statement . value ) {
1956
- let returnType = flow . returnType ;
1957
1957
if ( returnType == Type . void ) {
1958
1958
this . compileExpressionRetainType ( statement . value , returnType , WrapMode . NONE ) ;
1959
1959
this . error (
@@ -1974,6 +1974,13 @@ export class Compiler extends DiagnosticEmitter {
1974
1974
1975
1975
// Remember whether returning a properly wrapped value
1976
1976
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 ( ) ;
1977
1984
}
1978
1985
1979
1986
// If the last statement anyway, make it the block's return value
You can’t perform that action at this time.
0 commit comments