Skip to content

engine: SUM(pop[coast]) error blames pop, not the subrange coast #1052

Open

Description

@bpowers

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

Activity

  1. added
    engine
    on Oct 12, 2026
  2. changed the title [-]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[/+] on Oct 12, 2026
  3. added
    enhancement
    and removed on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions