On Thu, Jan 7, 2021 at 7:48 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > > 1) the bit representing "remember that this was declared but no value
> > > was assigned"
> > > 2) the combination of that with PM_UNSET that represents "functionally
> > > behaves like NULL"

After «unset», PM_UNSET would be set, and I don't immediately see why bit #1
should be tested at all if if PM_UNSET is set.

Bit #1 is tested for "typeset -p var".  If PM_UNSET is set and bit #1 is not, then "typeset -p" outputs nothing; but we want typeset -p to output a declaration (with no assignment).
 
If the «unset» is followed by
an assignment and/or (re-)declaration, the value of bit #1 can then be set
properly, and PM_UNSET cleared.  Makes sense?

Bit #1 has to be cleared on explicit unset, and is irrelevant on assignment because PM_UNSET is cleared on assignment.  However, it's most convenient to clear bit #1 on assignment because that eliminates one special case on "typeset var=value" (as opposed to "typeset var").