@@ -2485,90 +2485,6 @@ private bool canInferAttributes(FuncDeclaration fd, Scope* sc)
24852485 return false ;
24862486}
24872487
2488- /* ********************************************
2489- * In the current function 'sc.func', we are calling 'fd'.
2490- * 1. Check to see if the current function can call 'fd' , issue error if not.
2491- * 2. If the current function is not the parent of 'fd' , then add
2492- * the current function to the list of siblings of 'fd' .
2493- * 3. If the current function is a literal, and it's accessing an uplevel scope,
2494- * then mark it as a delegate.
2495- * Returns true if error occurs.
2496- */
2497- bool checkNestedFuncReference (FuncDeclaration fd, Scope* sc, Loc loc)
2498- {
2499- // printf("FuncDeclaration::checkNestedFuncReference() %s\n", toPrettyChars());
2500- if (auto fld = fd.isFuncLiteralDeclaration())
2501- {
2502- if (fld.tok == TOK .reserved)
2503- {
2504- fld.tok = TOK .function_;
2505- fld.vthis = null ;
2506- }
2507- }
2508- if (! fd.parent || fd.parent == sc.parent)
2509- return false ;
2510- if (fd.ident == Id.require || fd.ident == Id.ensure)
2511- return false ;
2512- if (! fd.isThis() && ! fd.isNested())
2513- return false ;
2514- // The current function
2515- FuncDeclaration fdthis = sc.parent.isFuncDeclaration();
2516- if (! fdthis)
2517- return false ; // out of function scope
2518- Dsymbol p = fd.toParentLocal();
2519- Dsymbol p2 = fd.toParent2();
2520- // Function literals from fdthis to p must be delegates
2521- ensureStaticLinkTo(fdthis, p);
2522- if (p != p2)
2523- ensureStaticLinkTo(fdthis, p2);
2524- if (! fd.isNested())
2525- return false ;
2526-
2527- // The function that this function is in
2528- bool checkEnclosing (FuncDeclaration fdv)
2529- {
2530- if (! fdv)
2531- return false ;
2532- if (fdv == fdthis)
2533- return false ;
2534- // printf("this = %s in [%s]\n", this.toChars(), this.loc.toChars());
2535- // printf("fdv = %s in [%s]\n", fdv .toChars(), fdv .loc.toChars());
2536- // printf("fdthis = %s in [%s]\n", fdthis.toChars(), fdthis.loc.toChars());
2537- // Add this function to the list of those which called us
2538- if (fdthis != fd)
2539- {
2540- bool found = false ;
2541- for (size_t i = 0 ; i < fd.siblingCallers.length; ++ i)
2542- {
2543- if (fd.siblingCallers[i] == fdthis)
2544- found = true ;
2545- }
2546- if (! found)
2547- {
2548- // printf("\tadding sibling %s to %s\n", fdthis.toPrettyChars(), toPrettyChars());
2549- if (! sc.intypeof && ! sc.traitsCompiles)
2550- {
2551- fd.siblingCallers.push(fdthis);
2552- fd.computedEscapingSiblings = false ;
2553- }
2554- }
2555- }
2556- const lv = fdthis.getLevelAndCheck(loc, sc, fdv, fd);
2557- if (lv == fd.LevelError)
2558- return true ; // error
2559- if (lv == - 1 )
2560- return false ; // downlevel call
2561- if (lv == 0 )
2562- return false ; // same level call
2563- return false ; // Uplevel call
2564- }
2565- if (checkEnclosing(p.isFuncDeclaration()))
2566- return true ;
2567- if (checkEnclosing(p == p2 ? null : p2.isFuncDeclaration()))
2568- return true ;
2569- return false ;
2570- }
2571-
25722488/* ***************************************************
25732489 * Check whether result variable can be built.
25742490 * Returns:
0 commit comments