stan-dev / stan-dev/rstan

rstan::stanc doesn't always return an object

Open
#342 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

stanc doesn't do as the doc says. It only returns an object when it is successful. When it is unsuccessful, it doesn't return.

Description:

It's hard to use stanc programmatically due to inconsistent output.

Reproducible Steps:
library(rstan)

r <- rstan::stanc(model_code = "foo")
str(r)
Current Output:
> r <- rstan::stanc(model_code = "foo")
SYNTAX ERROR, MESSAGE(S) FROM PARSER:


ERROR at line 1

  1:    foo
       ^

PARSER EXPECTED: <model declaration (or perhaps an earlier block)>
Error in rstan::stanc(model_code = "foo") : 
  failed to parse Stan model 'foo' due to the above error.
> str(r)
Error in str(r) : object 'r' not found
Expected Output:
> r <- rstan::stanc(model_code = "foo")
SYNTAX ERROR, MESSAGE(S) FROM PARSER:


ERROR at line 1

  1:    foo
       ^

PARSER EXPECTED: <model declaration (or perhaps an earlier block)>
Error in rstan::stanc(model_code = "foo") : 
  failed to parse Stan model 'foo' due to the above error.
> str(r)
List of 5
 $ status       : logi FALSE
 $ model_cppname: <not sure what goes here>
 $ cppcode      :  <should be empty>
 $ model_name   : chr "anon_model"
 $ model_code   : atomic [1:1] model { }
  ..- attr(*, "model_name2")= chr "anon_model"
RStan Version:

2.12.1

R Version:

3.3.1

Operating System:

Mac OS X 10.11.6.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with rstan::stanc(model_code = "foo") and compare it with the documented return shape. Trace the stanc entry point to see how unsuccessful parsing is handled; done means the call returns a five-element result with status FALSE and empty generated code instead of leaving the assignment unset.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.