Implements elimination of unreachable statements and expression within an AST already processed by early transf. The transformation makes sure that a non-returning statement is not immediately followed by other code.
For example, for:
return 1 echo "a"
The echo statement needs to be removed. This makes further processing easier, since detecting whether a block of code returns is now possible by inspecting just the trailing AST node.
For later inspection, all non-returning statements (such as break, return, etc.) have noreturnType assigned as the type.
Procs
proc eliminateUnreachable(graph: ModuleGraph; n: PNode): PNode {....raises: [], tags: [].}
- Entry point into the pass. Removes all unreachable statements/expression, making sure that a non-returning statement is always the last statement in a block of code. Source Edit