Open alashworth opened 5 years ago
Comment by bob-carpenter
Monday Aug 14, 2017 at 11:31 GMT
The behavior you cite is intentional and the error message is correct.
The parameters
block consists of a sequence of variable declarations. A single semicolon (;
) doesn't constitute a variable declaration.
On the other hand, if you look at contexts that allow statements, you'll find double semicolons are OK because ;
is a well-formed statement.
transformed data {
real x;
x = 10; ;
}
Obviously if you filed this as a bug report, you think the behavior should be changed.
I see two ways that could work.
we change the grammar and AST to allow empty variable declarations and make sure all the generator code, etc., doesn't generate anything when it sees them.
we somehow sneak a lit(";")
into the sequence of variable declarations in a way that doesn't do anything to the semantics.
I don't like (1) because I don't think there should be empty declarations. With (2), the question is how to finagle the grammar. I'm thinking it'd have to be something like this:
variable_declarations ::= -lit(";") << variable_declarations
| ...
I think the type of the lit
will just disappear, but we'll need to check that.
Comment by betanalpha
Monday Aug 14, 2017 at 13:53 GMT
I am very happy keeping the current behavior as a parser error, but then I would recommend a better error message. The problem with the current message is that the naive user (i.e. me) might have their eye drawn to the well-posed line and then get frustrated at not understanding why it's not working. Can we explicitly check for empty variable declaration and give a more explicit message, or even just add "whitespace lines with no variable declaration are also not allowed" in the existing message?
Description:
Extra semicolons ending a line throw a parser error despite the fact that an empty line causes no problems.
Reproducible Steps:
Current Output:
Expected Output:
No error or something more explicit like "Double semicolons not allowed".
Current Version:
v2.16.0