Skip to content

Commit

Permalink
Document alternative way to detect nested functions
Browse files Browse the repository at this point in the history
...for memoryCorruptionCheck.
  • Loading branch information
zorael committed Feb 17, 2025
1 parent d819f74 commit ea22607
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/kameloso/plugins/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -4447,6 +4447,21 @@ auto memoryCorruptionCheck()
{
assert(__ctfe, "`memoryCorruptionCheck` should only be used as a compile-time string mixin.");

/+
// Alternative approach, doesn't work with doubly-nested functions
enum _sentinelChild = 0;
static if (isSomeFunction!(__traits(parent, __traits(parent, _sentinelChild))))
{
enum _funName = __MODULE__ ~ '.' ~
__traits(identifier, __traits(parent, __traits(parent, _sentinelChild)));
}
else
{
enum _funName = __FUNCTION__;
}
+/

enum mixinBody =
"{
import kameloso.string : countUntilLastOccurrenceOf;
Expand Down

0 comments on commit ea22607

Please sign in to comment.