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
- bash -n — Running bash with -n, which reads and parses a script but runs nothing, reporting syntax errors only.
- command not found — The error bash prints, with exit status 127, when a command name matches no alias, function, builtin or file on PATH.
- end of file — The point where input runs out; also, by convention, the word EOF used to end a here document.
- IndentationError — A kind of syntax error raised when lines are indented inconsistently or a block is missing its indented body.
- runtime error — An error that happens while a program is running, such as dividing by zero or using an undefined name, raised as an exception.
- exception — An error object a program raises to stop normal flow and report that something went wrong.
Taught in
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Debugging: set -x, bash -n And Reading The Error — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- Integer Arithmetic And Precedence — Hands-on Python: Complete Video Course & Book
- Strings, Delimiters And Concatenation — Hands-on Python: Complete Video Course & Book
- Variables And Assignment — Hands-on Python: Complete Video Course & Book
- CGI: Dynamic Web Pages — Hands-on Python: Complete Video Course & Book
- Reading Error Messages — Hands-on Python: Complete Video Course & Book
- Forty Minutes, Thirty Items: How PCEP Is Run — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Interpreter, Compiler, And What Counts As Syntax — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Literals, Names And Four Number Bases — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Fundamentals Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Tuples, And The Comma That Makes Them — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Parameters, Arguments And Scope — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Try, Except, Else And Finally — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Functions And Exceptions Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Twelve Traps, One Shape Each — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Your Own Modules And Packages — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Classes, Objects And Two Stacks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Inheritance, super() And Polymorphism — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Multiple Inheritance, The MRO And Diamonds — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- List Comprehensions, Filtered And Nested — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Lambdas, map() And filter() — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Closures: Functions That Remember — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Comprehensions, Closures And Files Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep