-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
declare and define does not work at the top of a block without curly braces #2610
Comments
a combined variable declaration and definition is a variable declaration; it is not a statement, according to the current set of grammars. the body of a for loop can be either a single statement or a sequence of statements.
the parser is doing the right thing here; agreed, the error message could be better. |
What we want to do is replace this issue with a feature request to turn variable declarations so that local variable declarations may be interleaved. It's awkward with the implicit block-variable/statement split in the blocks with statements---the statements start after the last declaration. |
Why would we want this to parse? Is there any reason to declare a local variable and never use it? I agree that mixing variable declarations and statements is useful, but that seems like a different issue. |
We want it to parse because it allows the syntactic definitions to be simple rather than tied up with semantics. For example, C++ allows you to write:
and the compiler does not even produce a warning. Even if it's just |
Hmm. OK. So maybe the grammar (and stanc3) should be changed then? I can't say I'm fully convinced this is useful. It might simplify the grammar a bit, but it's also work to implement and it would only allow the users to do something useful. If people feel strongly about this though, it wouldn't be hard to do (just would take away some time from other things). |
Summary:
Declare and define does not work at the top of a block without curly braces.
Description:
There is a parser error if you attempt to declare and define does not work at the top of a block without curly braces.
Reproducible Steps:
Parse this
Current Output:
Expected Output:
Nothing
Additional Information:
None
Current Version:
v2.18.0
The text was updated successfully, but these errors were encountered: