From D15773: It seems there is a behavior difference when using #pop!some_context on the main context ("_profile"). For example, formerly, when doing #pop!some_context on the main context, "some_context" was stacked on top of the main context, it did not replace it. Now, in KF5.50.0, the main context is removed from de "stack" and replaced by "some_context". In the AppArmor XML file I use #pop#pop!some_context in general to finish a rule and, in some cases, #pop!some_context is done in the main context, which produces the error in large files, since it is not a behavior that I envisioned.
In KTextEditor, it was not possible to #pop the main context (is that correct @cullmann ?).
In KSyntaxHighlighting, with #pop!someContext you now can define a new main context.
Task: Evaluate whether this is an issue, and if we need to change this.