It:
"A" .. "F"
satisfies the syntax of a range ; it consists of simple_expression , followed by .. , and then another simple_expression . Therefore, this is not a syntax error.
It is still invalid; in particular, this is a semantic error. Syntax is not the only thing that determines whether a piece of code is valid or not. For example, "foo" * 42 is a syntactically valid expression, but it is semantically invalid because there is no * operator for a string and an integer (unless you write your own).
A discrete type is either an integer type or an enumeration type. Integer , Character and Boolean are examples of discrete types. Floating-point types, array types, pointer types, record types, etc. They are not discrete types, therefore expressions of these types cannot be used in the range for discrete_subtype_indication .
It:
type T is array ("A" .. "F") of Integer;
probably supposed:
type T is array ('A' .. 'F') of Integer;
String literals are of type String , which is an array type. Character literals are of type Character , which is an enumeration type and therefore a discrete type.
In response to another comment, you wrote:
Unfortunately, I cannot replace string literals with character literals and recompile the code ...
If so, then this is pretty unfortunate. The code you posted is simply invalid; it will not compile. Your only options are to change it or not to use it.
source share