Skip to content

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

@VMatthijs

Description

@VMatthijs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions