Ahadu 2.0
አማርኛ

Reading errors

What the language tells you when something is wrong

Making mistakes is part of learning. The good news is that Ahadu says clearly what went wrong.

Every error carries three things: a code, a message, and a place.

Open in playground This program fails on purpose
[AH3001] "ያልተሰየመ" የሚባል ተለዋጭ አልተገለጸም።: መስመር 1 ላይ: 4ኛው ካራክተር

AH3001 is the code. The message states the problem. The line and column say where to look.

Three kinds of error

The number the code starts with tells you when the problem was found.

AH1 — lexical

Found while splitting the text into words. A character that means nothing:

Open in playground This program fails on purpose
[AH1001] የማይታወቅ ካራክተር አለ።: መስመር 1 ላይ: 7ኛው ካራክተር

Or indentation that does not line up:

Open in playground This program fails on purpose
[AH1002] የመስመር መጀመሪያ ክፍተት ስተት፡: መስመር 2 ላይ: 1ኛው ካራክተር

AH2 — syntax

The words are fine but their arrangement is not:

Open in playground This program fails on purpose
[AH2002] የመዝጊያ ቅንፍ ")" ረስተዋል። የመክፈቻው በመስመር 1 ላይ ነው።: መስመር 1 ላይ: 11ኛው ካራክተር

Both of these are found before the program starts, so you are told without a single line having run.

AH3 — runtime

Raised while the program runs. Everything before it really did happen.

Open in playground This program fails on purpose
[AH3003] በዘሮ ማካፈል አይቻልም።: መስመር 2 ላይ: 4ኛው ካራክተር

Dividing by zero cannot be spotted while reading the program — whether the divisor is zero is only known once it runs. That is exactly why it is an AH3.

This grouping is a promise about when a problem can be detected, not a filing system. It is why AH3003 could never be an AH2.

Errors you will meet

Code Meaning
AH3001 a variable was used before it was given a value
AH3003 division by zero
AH3008 a position outside the collection was asked for
AH1002 the indentation at the start of a line is wrong
AH2002 a bracket was never closed

The full list is in the reference.

How to fix one

  1. Read the code — AH1 or AH3 tells you where to look
  2. Go to the line — start where the error points
  3. Change one thing — then run it again

Try fixing the examples above. For the first one, give ያልተሰየመ a value before using it.

Exercise

This program has three mistakes. Find them and fix them.

Open in playground This program fails on purpose
[AH1002] የመስመር መጀመሪያ ክፍተት ስተት፡: መስመር 4 ላይ: 1ኛው ካራክተር
Show the answer

The mistakes are: an indent that should not be there, a missing ፦, and a counter that never grows.

Open in playground This output was verified at build time
6