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

parser should flag use of _lxxf suffix on built-in functions in sampling statements #2595

Closed
mitzimorris opened this issue Aug 1, 2018 · 6 comments

Comments

@mitzimorris
Copy link
Member

Summary:

currently parser allows: foo ~ normal_lpdf(0, 1); due to suffix stripping logic; should flag as incorrect.

Description:

parser has suffix stripping logic for user-defined probability functions, but here this applies to built-in probability distributions as well.

Reproducible Steps:

this shouldn't compile but it does:

data {
  int<lower=0> N;
}
parameters {
  vector[N] foo;
}
model {
  foo ~ normal_lpdf(0, 1);
}

Current Output:

currently OK; should get flagged as error.

Expected Output:

Describe what you expect the output to be. Knowing the correct behavior is also very useful.

Additional Information:

Provide any additional information here.

Current Version:

v2.18.0

@bob-carpenter bob-carpenter added this to the 2.18.0++ milestone Aug 1, 2018
@VMatthijs
Copy link
Member

Stanc3 currently says

Semantic error at file "test.stan", line 8, characters 2-26:
   -------------------------------------------------
     6:  }
     7:  model {
     8:    foo ~ normal_lpdf(0, 1);
           ^
     9:  }
   -------------------------------------------------

Ill-typed arguments to '~' statement. No distribution normal_lpdf was found with the correct signature.

@bob-carpenter
Copy link
Member

bob-carpenter commented Dec 13, 2018 via email

@VMatthijs
Copy link
Member

OK. Just added a custom error message for these cases:

Semantic error at file "test.stan", line 8, columns 8-19:
   -------------------------------------------------
     6:  }
     7:  model {
     8:    foo ~ normal_lpdf(0, 1);
                 ^
     9:  }
   -------------------------------------------------

~-statement expects a distribution name without '_lpdf' or '_lcdf' suffix.

@bob-carpenter
Copy link
Member

bob-carpenter commented Dec 13, 2018 via email

@VMatthijs
Copy link
Member

Thanks! That was definitely a typo. Fixed now.

@mitzimorris mitzimorris removed this from the 2.18.1 milestone Dec 23, 2018
@mcol
Copy link
Contributor

mcol commented Feb 21, 2020

Fixed in stanc3. The error message is now the following:

Semantic error in 'test.stan', line 8, column 8 to column 19:
   -------------------------------------------------
     6:  }
     7:  model {
     8:    foo ~ normal_lpdf(0, 1);
                 ^
     9:  }
   -------------------------------------------------


~ statement should refer to a distribution without its "_lpdf" or "_lpmf" suffix.
For example, "target += normal_lpdf(y, 0, 1)" should become "y ~ normal(0, 1)."

@mcol mcol closed this as completed Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants