@@ -8234,10 +8234,11 @@ export class Compiler extends DiagnosticEmitter {
82348234 assert ( ! declaration . typeParameters ) ; // function expression cannot be generic
82358235 var flow = this . currentFlow ;
82368236 var actualFunction = flow . actualFunction ;
8237+ var anonymousFunctionName = declaration . name . text . length
8238+ ? declaration . name . text
8239+ : "~anonymous|" + ( actualFunction . nextAnonymousId ++ ) . toString ( ) ;
82378240 var prototype = new FunctionPrototype (
8238- declaration . name . text . length
8239- ? declaration . name . text
8240- : "anonymous|" + ( actualFunction . nextAnonymousId ++ ) . toString ( ) ,
8241+ anonymousFunctionName ,
82418242 actualFunction ,
82428243 declaration ,
82438244 DecoratorFlags . NONE
@@ -8599,8 +8600,14 @@ export class Compiler extends DiagnosticEmitter {
85998600 if ( ! originalFunctionInstance || ! this . compileFunction ( originalFunctionInstance ) ) return module . unreachable ( ) ;
86008601
86018602 // Create a new closure function for our original function
8603+ // TODO: Figure out why recursive closures don't work.
8604+ let anonymousFunctionName = functionPrototype . name + "~anonymous|" + ( actualFunction . nextAnonymousId ++ ) . toString ( ) ;
8605+ // Check if we are recursively calling the original actual function from our closure
8606+ if ( actualFunction . name . includes ( functionPrototype . name + "~anonymous|" ) ) {
8607+ // anonymousFunctionName += "~recursive|" + (Function.nextAnonymousRecursiveId++).toString();
8608+ }
86028609 let closureFunctionInstance = new Function (
8603- functionPrototype . name + "~anonymous|" + ( actualFunction . nextAnonymousId ++ ) . toString ( ) ,
8610+ anonymousFunctionName ,
86048611 functionPrototype ,
86058612 null ,
86068613 originalFunctionInstance . signature . toClosureSignature ( ) ,
0 commit comments