Merge pull request #1791 from WalterBright/scan

Original merge commit was:
https://github.com/D-Programming-Language/dmd/commit/fb27e49d5a48

But it was accidentally lost. This is an alternative commit for that.