Skip to content

restrict map_rect to legal data-only args #441

Open
@bob-carpenter

Description

@bob-carpenter

The following program should not compile because xi[i] isn't an entirely data-only expression. The value xi is a data variable, but the index i is local. That allows illegal programs like this to get compiled:

functions {
  vector f(vector beta, vector theta, data real[] xr, data int[] xi ) {
    return [1.0]';
  }
}
transformed data {
  vector[2] beta;
  vector[2] theta[2];
  real xr[2, 2];
  int xi[2, 2, 2];
}
parameters {
  real y;
}
transformed parameters {
  real s = 0;
  for (i in 1:2) {
    // BAD!  DATA CHANGING BETWEEN CALLS
    s += sum(map_rect(f, beta, theta, xr, xi[i]));
  }
}

These will produce different results with MPI turned on and turned off, which we don't ever want to happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions