Skip to content
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

better error message for program block names which contain typos #2367

Closed
mitzimorris opened this issue Jul 28, 2017 · 7 comments
Closed

better error message for program block names which contain typos #2367

mitzimorris opened this issue Jul 28, 2017 · 7 comments
Assignees
Labels

Comments

@mitzimorris
Copy link
Member

Summary:

When a Stan program has a model block name which is wrong, e.g. parameter instead of parameters, the parser error message is misleading:

PARSER EXPECTED: whitespace to end of file.
FOUND AT line <n>:

Description:

At the point where the parser encounters a bad model block name, the parse fails. Because all model blocks are optional, an empty file is a legal parse, hence the error message.

Reproducible Steps:

This program will result in the bad error message:

parameter {
  real x;
}

transformed parameter {
  real y = x;
}

model {
  x ~ normal(0, 1);
}

Current Output:

Current error message:

PARSER EXPECTED: whitespace to end of file.
FOUND AT line 1: 

Expected Output:

better error message would list allowed model block names, given model blocks already encountered.

Additional Information:

Current Version:

v2.16.0

@haotianlin
Copy link

I have the same problem, have you fix it now ?

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Aug 19, 2018 via email

@VMatthijs
Copy link
Member

Stanc3 currently says

Syntax error at file "test.stan", line 1, characters 0-9, parsing error:
   -------------------------------------------------
     1:  parameter {
                  ^
     2:    real x;
     3:  }
   -------------------------------------------------

Expected "functions {" or "data {" or "transformed data {" or "parameters {" or "transformed parameters {" or "model {" or "generated quantities {".

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 13, 2018 via email

@VMatthijs
Copy link
Member

It might be possible, but it would take me a while to figure out how to capture part of the input program in Menhir's custom errors. Changes to the parsing error messages which do not requires quoting the user program are easy to implement, however, and might amount to a better investment of our time. Quoting the user program in semantic errors is easy, on the other hand.

@madeleineth
Copy link

I'm not sure if it counts as the same issue, but I'm also seeing this message when I put the functions block (without a typo) after the data and parameters blocks. (rstan 2.18.2)

@rok-cesnovar
Copy link
Member

Stanc3 outputs the following

Syntax error in 'examples/bugs/test_model.stan', line 1, column 0 to column 9, parsing error:
   -------------------------------------------------
     1:  parameter {
                  ^
     2:    real x;
     3:  }
   -------------------------------------------------

Expected "functions {" or "data {" or "transformed data {" or "parameters {" or "transformed parameters {" or "model {" or "generated quantities {".

Will close, please reopen in the stanc3 repo if this needs to be improved further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants