Does hiding variables work in terms of blocks or line-by-line? Let's assume I have the following code:

declaration of a
declaration of b
..a..b
{
  ..a..b
  declaration of a 
  declaration of b
  ..a
}


In this code {} represent the inner block. declaration represents binding occurrence, and .. represent applied occurrence.

So my question is that is it legal to use the outer scope variables inside an inner scope and then redeclare them ? If so how does the hiding of outer variables system work (Does it start to work when it sees a redeclaration)? Thanks in advance.
It depends on the programming language.  It's up to each language to specify whether this is legal or not, and what it means.

In many languages this would be legal.  It is called variable shadowing.