syntax error

A mistake in the form of code, such as an unclosed bracket or an if without its matching end, that the language cannot understand and so will not run.

In more detail

The language checks the form of code before running it, so the faulty code never runs until the mistake is fixed. The place the error is reported is where the problem was noticed, which is often after where it was made, such as the line after an unclosed bracket. It differs from a run-time error, where valid code starts running and then fails.

Example

In Python the exception is SyntaxError, and IndentationError is a kind of syntax error.

Related terms

Taught in

References

Certification courses