@@ -578,15 +578,15 @@ export class Compiler extends DiagnosticEmitter {
578578 // compile statements
579579 var stmts : ExpressionRef [ ] | null = null ;
580580 if ( ! instance . is ( ElementFlags . DECLARED ) ) {
581- declaration = assert ( declaration ) ;
581+ declaration = assert ( declaration , "declaration expected" ) ;
582582 var previousFunction = this . currentFunction ;
583583 this . currentFunction = instance ;
584- var statements = assert ( declaration . statements ) ;
584+ var statements = assert ( declaration . statements , "implementation expected" ) ;
585585 stmts = this . compileStatements ( statements ) ;
586586 // make sure the top-level branch or all child branches return
587587 var allBranchesReturn = this . currentFunction . flow . finalize ( ) ;
588588 if ( instance . returnType != Type . void && ! allBranchesReturn )
589- this . error ( DiagnosticCode . A_function_whose_declared_type_is_not_void_must_return_a_value , assert ( declaration . returnType ) . range ) ;
589+ this . error ( DiagnosticCode . A_function_whose_declared_type_is_not_void_must_return_a_value , assert ( declaration . returnType , "return type expected" ) . range ) ;
590590 this . currentFunction = previousFunction ;
591591 }
592592
@@ -895,6 +895,7 @@ export class Compiler extends DiagnosticEmitter {
895895 this . error ( DiagnosticCode . A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement , statement . range ) ;
896896 return this . module . createUnreachable ( ) ;
897897 }
898+ this . currentFunction . flow . set ( FlowFlags . POSSIBLY_BREAKS ) ;
898899 return this . module . createBreak ( breakLabel ) ;
899900 }
900901
@@ -909,6 +910,7 @@ export class Compiler extends DiagnosticEmitter {
909910 this . error ( DiagnosticCode . A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement , statement . range ) ;
910911 return this . module . createUnreachable ( ) ;
911912 }
913+ this . currentFunction . flow . set ( FlowFlags . POSSIBLY_CONTINUES ) ;
912914 return this . module . createBreak ( continueLabel ) ;
913915 }
914916
@@ -1022,8 +1024,6 @@ export class Compiler extends DiagnosticEmitter {
10221024 }
10231025
10241026 compileReturnStatement ( statement : ReturnStatement ) : ExpressionRef {
1025- assert ( this . currentFunction ) ;
1026-
10271027 var expression : ExpressionRef = 0 ;
10281028 if ( statement . value )
10291029 expression = this . compileExpression ( < Expression > statement . value , this . currentFunction . returnType ) ;
@@ -1353,7 +1353,7 @@ export class Compiler extends DiagnosticEmitter {
13531353
13541354 convertExpression ( expr : ExpressionRef , fromType : Type , toType : Type , conversionKind : ConversionKind , reportNode : Node ) : ExpressionRef {
13551355 if ( conversionKind == ConversionKind . NONE ) {
1356- assert ( false ) ;
1356+ assert ( false , "concrete type expected" ) ;
13571357 return expr ;
13581358 }
13591359
@@ -1437,7 +1437,7 @@ export class Compiler extends DiagnosticEmitter {
14371437
14381438 // float to void
14391439 } else {
1440- assert ( toType . flags == TypeFlags . NONE ) ;
1440+ assert ( toType . flags == TypeFlags . NONE , "void type expected" ) ;
14411441 expr = this . module . createDrop ( expr ) ;
14421442 }
14431443
@@ -2296,11 +2296,10 @@ export class Compiler extends DiagnosticEmitter {
22962296
22972297 // otherwise make use of the temp. local
22982298 else {
2299- assert ( tempLocal ) ;
23002299 expr = this . module . createIf (
23012300 condition ,
23022301 right ,
2303- this . module . createGetLocal ( ( < Local > tempLocal ) . index , this . currentType . toNativeType ( ) )
2302+ this . module . createGetLocal ( assert ( tempLocal , "tempLocal must be set" ) . index , this . currentType . toNativeType ( ) )
23042303 ) ;
23052304 }
23062305 break ;
@@ -2331,10 +2330,9 @@ export class Compiler extends DiagnosticEmitter {
23312330
23322331 // otherwise make use of the temp. local
23332332 else {
2334- assert ( tempLocal ) ;
23352333 expr = this . module . createIf (
23362334 condition ,
2337- this . module . createGetLocal ( ( < Local > tempLocal ) . index , this . currentType . toNativeType ( ) ) ,
2335+ this . module . createGetLocal ( assert ( tempLocal , "tempLocal must be set" ) . index , this . currentType . toNativeType ( ) ) ,
23382336 right
23392337 ) ;
23402338 }
@@ -2345,7 +2343,7 @@ export class Compiler extends DiagnosticEmitter {
23452343 throw new Error ( "not implemented" ) ;
23462344 }
23472345 if ( possiblyOverflows && wrapSmallIntegers ) {
2348- assert ( this . currentType . is ( TypeFlags . SMALL | TypeFlags . INTEGER ) ) ;
2346+ assert ( this . currentType . is ( TypeFlags . SMALL | TypeFlags . INTEGER ) ) , "small integer type expected" ;
23492347 expr = makeSmallIntegerWrap ( expr , this . currentType , this . module ) ;
23502348 }
23512349 return compound
@@ -2366,7 +2364,7 @@ export class Compiler extends DiagnosticEmitter {
23662364 case ElementKind . GLOBAL :
23672365 if ( ! this . compileGlobal ( < Global > element ) ) // reports; not yet compiled if a static field compiled as a global
23682366 return this . module . createUnreachable ( ) ;
2369- assert ( ( < Global > element ) . type != Type . void ) ;
2367+ assert ( ( < Global > element ) . type != Type . void , "concrete type expected" ) ;
23702368 // fall-through
23712369
23722370 case ElementKind . LOCAL :
@@ -2429,7 +2427,7 @@ export class Compiler extends DiagnosticEmitter {
24292427 case ElementKind . GLOBAL :
24302428 if ( ! this . compileGlobal ( < Global > element ) ) // reports; not yet compiled if a static field compiled as a global
24312429 return this . module . createUnreachable ( ) ;
2432- assert ( ( < Global > element ) . type != Type . void ) ;
2430+ assert ( ( < Global > element ) . type != Type . void , "concrete type expected" ) ;
24332431 this . currentType = tee ? ( < Global > element ) . type : Type . void ;
24342432 if ( ( < Local > element ) . is ( ElementFlags . CONSTANT ) ) {
24352433 this . error ( DiagnosticCode . Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property , expression . range , ( < Local > element ) . internalName ) ;
@@ -2448,9 +2446,9 @@ export class Compiler extends DiagnosticEmitter {
24482446 this . error ( DiagnosticCode . Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property , expression . range , ( < Field > element ) . internalName ) ;
24492447 return this . module . createUnreachable ( ) ;
24502448 }
2451- assert ( resolved . targetExpression != null ) ;
2449+ assert ( resolved . targetExpression != null , "target expression expected" ) ;
24522450 targetExpr = this . compileExpression ( < Expression > resolved . targetExpression , this . options . target == Target . WASM64 ? Type . usize64 : Type . usize32 , ConversionKind . NONE ) ;
2453- assert ( this . currentType . classType ) ;
2451+ assert ( this . currentType . classType , "class type expected" ) ;
24542452 this . currentType = tee ? ( < Field > element ) . type : Type . void ;
24552453 var elementNativeType = ( < Field > element ) . type . toNativeType ( ) ;
24562454 if ( ! tee )
0 commit comments