-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Fix expose_stan_functions under Stanc 2.31 #1050
Conversation
I've also verified that this fixes the test failure for the |
@@ -31,7 +31,7 @@ expose_stan_functions_hacks <- function(code, includes = NULL) { | |||
code <- gsub("stan::math::accumulator<double>& lp_accum__, std::ostream* pstream__ = nullptr){", | |||
"std::ostream* pstream__ = nullptr){\nstan::math::accumulator<double> lp_accum__;", | |||
code, fixed = TRUE) | |||
code <- gsub("= nullptr", "= 0", code, fixed = TRUE) | |||
code <- gsub("= nullptr)", "= 0)", code, fixed = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there other patterns that we need to support here, such as "nullptr,"
, ",nullptr"
, or ", nullptr"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have said no, but the test failure under ubuntu is making me question that. I'll investigate and update the PR
Does this fix #954? |
It's bizarre, I can't replicate the test failures locally under MacOS, Ubuntu, or Windows |
c48da76
to
9e2296e
Compare
To reduce the artifact size if check is failed.
Narrowed it down a bit more. The test will fail when run through |
Ah, it looks like May have to just remove the test entirely (after testing locally) |
I see. Could probably use Catch: https://testthat.r-lib.org/reference/use_catch.html. Anyway, it works on my local machine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Part of the
expose_stan_functions_hacks
code was replacing= nullptr
with= 0
, intended for thepstream__ = nullptr
default argument. However this causes a compilation failure under 2.31, since the generated code now includes default template parameters withnullptr
which are then replaced.This PR updates the regex to only replace the
nullptr
if it's followed by a parenthesis - as the function definitions will always generate thepstream__ = nullptr
as the last argument. I've also added a basic test.This will also need to be backported to 2.26