Automatic keyword

Why we cannot declare any variable with automatic outside task or function?

In reply to spyder26060:

The lifetime of an automatic variable is tied to the procedural scope where the variable is declared. This means that the variable gets allocated when entering the scope and destroyed when exiting the scope. Procedural scopes include begin/end, fork/join blocks as well as tasks and functions. It does not make any sense to declare an automatic variable outside of a procedural scope.

You should read: https://resources.sw.siemens.com/en-US/white-paper-the-life-of-a-systemverilog-variable