Error Messages/40730
Example error messages
- Local variable K is not a valid index in the
Local x[K] := ...
construct.
- Variable Revenue is not a valid index in the
Local x[Revenue] := ...
construct.
Description
The declaration of a local value specifies one or more allowed indexes for the local. The specified "index" isn't actually an index.
Suppose, for example, that Revenue
is $1M -- which of course is not an index. Then you might see this error message in a declaration
Local cash_flow[Revenue] := ....
Maybe the author's intent was
Local cash_flow[Time] := ...
The error also appears with the following easy-to-make mistake:
LocalAlias K := Last_years_products_Idx;
Local x[ K,J ] :=....
The error occurs on the second line, but the mistake is on the first line. The intent here is for K
to serve as an alias for a longer index identifier, but because the right-hand side of an assignment (:=
) is evaluated, you would need to write
LocalAlias K := Handle(Last_years_products_Idx);
Local x[ K,J ] :=....
Without the Handle call, K
ends up aliasing the value of Last_years_products_Idx
instead of the object itself. If its value were a handle to and index, that would be fine. But when its value is just a list, that is not an index.
Enable comment auto-refresher