-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
[BUG] --standalone-functions
ignores undefined functions (external c++)
#1297
Comments
I think that the only thing needed is the |
The current standalone-functions functionality always exposes functions, not templates, and always puts them outside the model namespace, so adding a comment there would make this very different behavior. The easiest "fix" for this is just making this match statement always equivalent to the current "Some" case: stanc3/src/stan_math_backend/Lower_functions.ml Lines 319 to 321 in a490a09
That will introduce a new issue where functions {
real retreal(real x);
real retreal(real x) {
return x;
}
} would now output duplicate definitions, but that should be fixable. I think this oversight is simply because we don't want to generate two signatures if it was a "normal" (i.e. not for external C++) forward decl, and right now it is annoying to tell these two cases apart (one motivation for ideas in #1278) . |
Ah gotcha. I've got no strong preference on a particular approach. It's for making external c++ compatible with expose_functions() in cmdstanr, so I'm happy with whatever works! |
I think I have a reasonable fix for this which also fixes another known issue with external C++ (we don’t generate the necessary functors to call them in Higher order functions) |
The
--standalone-functions
flag doesn't produce the same function code and// [[stan::function]]
decorator if an external function is declared with the--allow-undefined
flag.For example, the following model:
Parses to:
Whereas:
Parses to:
The text was updated successfully, but these errors were encountered: