Why is an enumeration out of range error not cought compile time lazarus / 61-Beginners ---------------------------------------------------------------------- Anonimista · 2019-09-11 18:53 I have this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; type    shape = (rectangle, square, ellipse, circle);    color = (red, yellow, green);    sex = (male, female); var    s: sex;    c: color;  begin     s := male;    writeln(s);    writeln(succ(s));    { writeln(pred(s)); -- Runtime error 107 }    writeln(ord(pred(s)));     c := red;    writeln(c);    writeln(succ(c));     readln; end. The error is "Invalid enumeration     Reported when a text representation of an enumerated constant cannot be created in a call to str or write(ln)." Can anybody explain why this error is not caught at compile time. Is it to keep the compiler simple? ---------------------------------------------------------------------- jamie · 2019-09-11 19:15 Delphi help says not to use a PRED on a WRITE operation because WRITE does not have a way to translate it to something usable.  In your example, you are actually faulting it because you are going outside the boundaries. ---------------------------------------------------------------------- Anonimista · 2019-09-11 19:22 hm, I only get the error when ord(s) is -1. I guess my question is why are enumeration bounds not checked at compile time. ---------------------------------------------------------------------- marcov · 2019-09-11 19:22 I think pred(s) and succ(s) are simply not inlined as intrinsics in this code. Then the increment/decrement doesn't happen in compiletime, so no error. ---------------------------------------------------------------------- Anonimista · 2019-09-11 19:43 Thanks! New to freepascal and not quite understand much but it is what it is.