Questions: Error Recovery in Compilation

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A compiler uses phrase-level error recovery to insert a missing semicolon and then emits 30 additional error messages, most of which are spurious. What most likely happened?

AThe program genuinely contains 31 independent syntax errors
BThe inserted semicolon repaired the syntax but left the parser in a state inconsistent with the programmer's intent, causing cascading errors downstream
CPhrase-level recovery is inherently broken and should never be used in production compilers
DThe synchronization point chosen was correct, but the grammar is ambiguous
Question 2 Multiple Choice

When a type checker encounters an expression that could not be successfully type-checked due to an earlier error, it assigns the expression a special 'error type' compatible with all other types. Why?

ATo immediately halt compilation and prevent code generation from producing incorrect output
BTo allow type checking to continue past the damaged expression without generating spurious 'type mismatch' errors for every subsequent use of that expression
CBecause the error type is the most precise type inference possible given incomplete information
DTo mark the expression for deletion during a subsequent cleanup pass
Question 3 True / False

Panic-mode error recovery attempts to fix the syntax error by inserting or deleting minimal tokens, then resumes parsing from the exact point of failure.

TTrue
FFalse
Question 4 True / False

Production compilers continue parsing after encountering a syntax error specifically so that developers can see and fix multiple errors in a single compilation pass.

TTrue
FFalse
Question 5 Short Answer

Describe the core tension between panic-mode error recovery and phrase-level recovery. What does each strategy optimize for, and what does each sacrifice?

Think about your answer, then reveal below.