stan-dev / stanc3

The Stan transpiler (from Stan to C++ and beyond).
BSD 3-Clause "New" or "Revised" License
138 stars 44 forks source link

[BUG] Array declaration no longer canonicalizes from deprecated format #1410

Closed bamarco closed 3 months ago

bamarco commented 3 months ago

Current Behavior:

when I run this command on code with a deprecated array declaration:

stanc array-deprecation-error.stan --canonicalize=deprecations

it produces the error:

Syntax error in 'array-deprecation-error.stan', line 8, column 15 to column 16, parsing error:
   -------------------------------------------------
     6:  data {
     7:    int an_int;
     8:    int some_ints[an_int]; // problem here
                        ^
     9:  }
   -------------------------------------------------

";" expected after variable declaration.

Expected Behavior:

Convert deprecated code to:

data {
  int an_int;
  array[some_ints] int an_int; // problem here
}

Model Code

Model which exhibits the issue stanc3 v2.34.0 (Unix) worked in a previous version (unsure which one) ```stan // Please put your code here data { int an_int; int some_ints[an_int]; // problem here } ```

Environment:

Anything else:

WardBrian commented 3 months ago

Deprecations are only guaranteed to be formattable during the warning window and for one version after removal. For the array syntax that means you can use any compiler from 2.26-2.33, but not 2.34, as the code for handling the old syntax has been removed