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

_log, _lpmf, _lpdf accepted in ~-statements #2801

Closed
VMatthijs opened this issue Aug 15, 2019 · 1 comment
Closed

_log, _lpmf, _lpdf accepted in ~-statements #2801

VMatthijs opened this issue Aug 15, 2019 · 1 comment
Milestone

Comments

@VMatthijs
Copy link
Member

Summary:

Currently, we are allowed to use the _log, _lpmf, _lpdf suffixes for distributions, even in a ~-statement. According to @bob-carpenter , that should not be allowed.

Description:

The following is valid Stan code:

functions { 
   real user_def_lpdf(real y) return 2; 
   real user_def_2_log(real y) return 2;
   real user_def_3_lpmf(int y) return 42;
}
model {
    1 ~ normal_lpdf(2, 3);
    2 ~ user_def_lpdf();
    3 ~ user_def_2_log();
    8 ~ poisson_lpmf(5);
    10 ~ user_def_3_lpmf();
}

but it should not be. Instead, the user should write:

functions { 
   real user_def_lpdf(real y) return 2; 
   real user_def_2_log(real y) return 2;
   real user_def_3_lpmf(int y) return 42;
}
model {
    1 ~ normal(2, 3);
    2 ~ user_def();
    3 ~ user_def_2();
    8 ~ poisson(5);
    10 ~ user_def_3();
}

or

functions { 
   real user_def_lpdf(real y) return 2; 
   real user_def_2_log(real y) return 2;
   real user_def_3_lpmf(int y) return 42;
}
model {
    target += normal_lpdf(1| 2, 3);
    target += user_def_lpdf(2);
    target += user_def_2_log(3);
    target += poisson_lpmf(8);
    target += user_def_3_lpmf(10);
}

Reproducible Steps:

Compile the model above.

Current Output:

It runs.

Expected Output:

Some informative syntax error message.

Current Version:

v2.20.0

@rok-cesnovar
Copy link
Member

Fixed in stanc3

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

3 participants