I've confused things by writing as I think and mixing terminology.
The parsing phase happens early on, presumably converting to bytecode (tokenising). We know this happens because things like functions are identified and stored in memory.
At this parse stage the state of variables and the "explicit" setting are unknown. No variable definition occurs during this initial phase.
The interpreter then runs through the code. The interpreter will see the variable and will need to put a reference to it on the internal stack - at this stage it will determine whether the variable exists. The expression will then be added to the stack.
Now the expression is evaluated and the result pushed onto the stack. The result is popped, the next operator (assignment) is popped and the variable reference popped.
So, while the process evaluates the expression before assigning the result to the variable, the variable is declared when it is initially pushed onto the stack.
A simple test confirms that variables are only declared when needed, i.e. when "executed". This test will not error as the code with the undelcared variable is never executed:
code:
$gNull=SetOption("Explicit","ON")
If "true" Exit 0 Else $Undeclared=1 EndIf
Another test to confirm this - the messagebox will not appear as the variable has not been declared, and this is validated before the assignment:
code:
$gNull=SetOption("Explicit","ON")
$Undeclared=MessageBox("Test Message","Test Message")
A final test - there are two undeclared variables, but the one on the LHS of the assignment is the one that causes the error:
code:
$gNull=SetOption("Explicit","ON")
$Undeclared1=$Undeclared2