Error Messages/43865


Error message

You have a declaration of a local value in the form
    Var x[Null] := expr
where the Null denotes that the implicit dimension should be allowed in x. 
However, the expr has more than one possible implicit dimension, which makes this ambiguous. 

Description

Here is an example that can cause this error.

Var a := 1..3;
Var b := 1..4;
Var c[Null] := a + b;
Max(c)

In this example, a and b are both names for list values -- i.e., each is an implicit dimension. Neither a nor b is declared to be an index. Hence, a + b has two implicit dimensions. Because it is still possible to name each of these while a and b remain in lexical scope, the combination of two implicit dimensions does not yet cause an error. However, in c's dimensionality declaration, the Null indicates that the implicit dimension should be allowed for c. This error arises because both the dimensions of a + b are implicit, and hence, it is ambiguous as to which of these you want to allow.

Remedies

Numerous remedies are possible. You could simply be explicit about which dimension, e.g.,:

Var a := 1..3;
Var b := 1..4;
Var c[a] := a + b;
Max(c)

So in c's body, it'll have the 1..3 implicit dimension (Max will always return 4). You could make one of the dimensions explicit, e.g.,

Var a := 1..3;
Index b := 1..4;
Var c[Null] := a + b;
Max(c)

Now a is the only implicit dimension. You could also ensure there is an unnamed implicit dimension, which will take precedence over a named implicit dimension.

Var b := 1..4;
Var c[Null] := (1..3) + b;
Max(c)

See Also

Comments


You are not allowed to post comments.