HAL-319: Scope assignment and statement context resolution
Fix HAL-317