IOW, if a context-local variable is not found in the current context, Nasm is no longer going to search the "upper" context for it.
Yep, that's the plan.
To be more explicit, if a context-local variable is not found in the referenced context, with the number of
$ signs determining how many context levels up to reference starting from zero (%$), then NASM will no longer attempt to "search until I find something that may or may not be intended/relevant" across all contexts.
So this...
main.asm:14: warning: __CONTEXT__0 __CONTEXT__0
main.asm:16: warning: __CONTEXT__1 __CONTEXT__0
main.asm:18: error: `ctxname': context stack is only 1 level deep
main.asm:18: warning: __CONTEXT__0 %$$ctxname
... will become this...
main.asm:14: warning: %$ctxname __CONTEXT__0
main.asm:16: warning: __CONTEXT__1 __CONTEXT__0
main.asm:18: error: `ctxname': context stack is only 1 level deep
main.asm:18: warning: __CONTEXT__0 %$$ctxname
... and sanity will be restored.
As for the last %warning producing an error, Rob is correct, you are trying to reference a non-existent context via %$$ctxname, because you already
%poped it prior to the last %warning.