Skip to content

expose_functions: warning when function uses reserved word? #1134

@WardBrian

Description

@WardBrian

Because of the need to compile as valid C++, there is sometimes name mangling applied by the stanc compiler. This can affect both function names and function argument names, and I believe was the cause of epinowcast/primarycensored#258

For example:

functions {
  real min(real max, real class) {
    return max - class;
  }
}

Generates the following

// [[stan::function]]
double
_stan_min(const double& _stan_max, const double& _stan_class, std::ostream*
          pstream__ = nullptr) {
  return reserved_model_namespace::_stan_min(_stan_max, _stan_class,
           pstream__);
}

The function name could be fixed by adding the optional ("name") to the Rcpp:Export comment, but I don't think anything can be done about the argument names. Maybe cmdstanr should detect this _stan prefix and give a warning?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions