Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong higher-order function error msg from parser #2578

Closed
yizhang-yiz opened this issue Jul 10, 2018 · 2 comments
Closed

wrong higher-order function error msg from parser #2578

yizhang-yiz opened this issue Jul 10, 2018 · 2 comments

Comments

@yizhang-yiz
Copy link

Summary:

Wrong error message with non-existent higher-order function.

Description:

If a higher-order function does not exist, parser error message points to its functor argument instead of the higher-order function itself.

Reproducible Steps:

The following variant of ODE example from the manual, replacing integrate_ode_bdf with non-existent foobar

functions {
real[] sho(real t,        // time
           real[] y,      // state
           real[] theta,  // parameters
           real[] x_r,    // data (real)
           int[] x_i) {   // data (integer)
  real dydt[2];
  dydt[1] = y[2];
  dydt[2] = -y[1] - theta[1] * y[2];
   return dydt;
}
  
}

data {
  int<lower=1> T;
  real y[T*2];
  real t0;
  real ts[T];
}
transformed data {
  real x_r[0];
  int x_i[0]; }
parameters {
  real y0[2];
  vector<lower=0>[2] sigma;
  real theta[1];
}
model {
  real y_hat[T,2];
  sigma ~ cauchy(0, 2.5);
  theta ~ normal(0, 1);
  y0 ~ normal(0, 1);
  y_hat = foobar(sho, y0, t0, ts, theta, x_r,
                             x_i);
  for (t in 1:T)
    y[t] ~ normal(y_hat[t][1], sigma);
  for (t in 1:T)
    y[t+T] ~ normal(y_hat[t][2], sigma);
}

Current Output:

variable "sho" does not exist.

Expected Output:

Function foobar not found.

Additional Information:

Provide any additional information here.

Current Version:

v2.17.1

@yizhang-yiz yizhang-yiz changed the title wrong error msg from parser wrong higher-order function error msg from parser Jul 10, 2018
@yizhang-yiz yizhang-yiz reopened this Jul 10, 2018
@VMatthijs
Copy link
Member

stanc3 currently says

Semantic error at file "test.stan", line 34, characters 10-80:
   -------------------------------------------------
    32:    theta ~ normal(0, 1);
    33:    y0 ~ normal(0, 1);
    34:    y_hat = foobar(sho, y0, t0, ts, theta, x_r,
                   ^
    35:                               x_i);
    36:    for (t in 1:T)
   -------------------------------------------------

A returning function was expected but an undeclared identifier foobar was supplied.

Is that any better?

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 13, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants