Repository navigation
Description
x[region] = SUM(pop[coast]), where coast is a subrange of region, is refused with an error that blames pop instead of the subscript coast, and does not mention the spelling that works, SUM(pop[*:coast]).
Refusing is right; the message should name coast, mark its span, and suggest pop[*:coast].
Example
region = {north, south, east}, coast = {north, east}, pop[region] a stock starting at 100, 200, 300.
| equation | result |
|---|---|
x[region] = SUM(pop[coast]) |
refused: mismatched_dimensions -- pop, no span |
x = SUM(pop[coast]) |
refused: dimension_in_scalar_context, span under coast |
x[region] = SUM(pop[*:coast]) |
400 400 400 |
x[coast] = SUM(pop[coast]) |
100 300 |
The first row's text was measured before the error-message rework in #1040 and later commits; the current wording was not re-checked, but by code reading the candidate refusals (dimensions_do_not_match, unpaired_read) still name the variable and its own dimensions, not the subscript.
Why it matters
Per XMILE 1.0 section 3.7.1 a dimension name inside a subscript stands for the current element of that dimension in the equation's own array, so coast is meaningless in an equation over region; slices use * and ranges.
Vensim's SUM(pop[coast!]) imports as pop[*:coast], so MDL models never hit this.
A modeler typing a subrange sum into the Simlin editor will, and the equation lexer has no !, so pop[coast] is the natural first try.
Seen only in a constructed model.
Fix
Where the subscript lowering finds a dimension name that matches no dimension of the equation, report it at the subscript's span, naming the dimension, and when it is a subrange of the source axis suggest pop[*:coast].
The scalar-equation error could carry the same suggestion.
Pointers
src/simlin-engine/src/compiler/context.rs:dimensions_do_not_match,unpaired_read,lower_index_expr3src/simlin-engine/src/ast/expr2.rs: theDimensionInScalarContextraise- engine: SUM(pop * 2) in an arrayed equation fails with a cryptic error #1051: another reducer refusal whose message should point at the
*spelling
Activity
[-]engine: SUM(pop[coast]) with coast a subrange the target does not range over is refused as "mismatched_dimensions -- pop" -- the diagnostic names the variable, not the subrange or the *:coast spelling that compiles[/-][+]engine: SUM(pop[coast]) error blames pop, not the subrange coast[/+]