What does "Max recursive depth reached" in the error log mean?

Sometimes when you are writing macros you can accidentally create macros that call themselves. For example,
   * Set BADMACRO = Is a %BADMACRO%
is recursive, because the definition contains the macro itself. Macros are automatically limited to 16 recursive levels, so if you really did define this macro you'd see this when you viewed the topic:
  • Set BADMACRO = Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a Is a BADMACRO
You'll also get a warning in the Foswiki logs:
Max recursive depth reached: Is a %BADMACRO%
It's not always obvious that a recursion is happening. For example, macro parameters are automatically expanded when the * Set statement is expanded for view.
   * Set AMACRO = %DEFAULT%
   * Set BMACRO = %AMACRO{%DEFAULT%}%
The expansion of %AMACRO in the definition of BMACRO will result in a Max recursion depth reached error, as the =%DEFAULT% macro is recursively evaluated. This doesn't affect the functioning of the macro, and can be safely ignored (we are looking for a fix, but haven't found an efficient solution yet).

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Debugging
Topic Summary Explaining recursive macros
Extension
Interested Parties
Related Topics
Topic revision: r1 - 15 Apr 2015, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy