IMO this case should not be allowed. On 2021/08/29 you wrote:
I thought about this case, and I have one scenario, where this behaviour can be useful. When the variable is declared as IMMUTABLE NOT NULL without not null default, then any access to the content of the variable has to fail. I think it can be used for detection, where and when the variable is first used. So this behavior is allowed just because I think, so this feature can be interesting for debugging. If this idea is too strange, I have no problem to disable this case.
I checked code, and this case is disallowed already
postgres=# CREATE IMMUTABLE VARIABLE xx AS int NOT NULL; ERROR: IMMUTABLE NOT NULL variable requires default expression