Machine-translated by Google. Questions are authored in English.
Top

Discussion

A duplicate declaration in the same scope is detected by

  • A.looking the name up in the current scope before installing it
  • B.comparing the two declarations after the whole parse is done
  • C.the parser
  • D.the scanner

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.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.