Semantic Analysis
Compiler phase that checks type consistency, verifies declarations, and ensures semantic correctness before code generation.
Syntax can be perfectly valid yet semantics completely wrong—assigning a string to an integer variable, calling a function with the wrong number of arguments, or referencing a variable never declared. Semantic analysis builds symbol tables, performs type checking, and catches these errors before a single machine instruction is generated. Type checking and type inference belong here.