diff --git a/peglib.h b/peglib.h index 7152e4e..76c9287 100644 --- a/peglib.h +++ b/peglib.h @@ -1003,6 +1003,9 @@ public: size_t len = static_cast(-1); if (!for_label_) { c.cut_stack.push_back(false); } + auto se = scope_exit([&]() { + if (!for_label_) { c.cut_stack.pop_back(); } + }); size_t id = 0; for (const auto &ope : opes_) { @@ -1030,8 +1033,6 @@ public: id++; } - if (!for_label_) { c.cut_stack.pop_back(); } - return len; }