A duplicate declaration in the same scope is detected by
Answer: A
Correct answer: looking the name up in the current scope before installing it
Only the current scope is searched, because a declaration in an enclosing scope is legitimately shadowed rather than duplicated. That single lookup before installation is what distinguishes an error from ordinary nesting, and it is why the check must happen at declaration rather than afterwards.
Please log in or register to report this question.