Skip to content

Inconsistency in allowed arguments to lpdf, lpmf, and _log functions #1045

@WardBrian

Description

@WardBrian

While reviewing #1044 @nhuurre discovered that these two functions are treated differently:

real foo_log(array[,] real x) {
  return sum(x[1]);
}
real foo_lpdf(array[,] real x) {
  return sum(x[1]);
}

Because UnsizedType.is_real_type doesn't check nested arrays, only 1-D ones.

I've asked @bob-carpenter and it seems the original intent was for any nested type to be possible, so the latter is the bug. Changing UnsizedType.is_real_type and UnsizedType.is_int_type should be the right thing to do here.

Additionally, there is nothing preventing a user from defining real foo_log(complex z) at the moment, which isn't possible for _lp[dm]f.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions