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

Non-returning function calls should be followed by semi-colon #2695

Closed
VMatthijs opened this issue Nov 16, 2018 · 4 comments
Closed

Non-returning function calls should be followed by semi-colon #2695

VMatthijs opened this issue Nov 16, 2018 · 4 comments
Assignees
Milestone

Comments

@VMatthijs
Copy link
Member

Summary:

Currently, non-returning function calls without semi-colon are allowed as statements. This seems like a bug in the parser.

Description:

The requirement that statements end in a semi-colon does not seem to be enforced for non-returning function calls.

Reproducible Steps:

Compile the following model

functions {
  void foo(real x) {
    print("quitting time");
    reject("user-specified rejection");
  }
}
transformed data {
  print("In transformed data");
}
parameters {
  real y;
} 
transformed parameters {
  real v;
  print("In transformed parameters");
  foo(v)
}
model {
  print("In model block.");
  y ~ normal(0,1);
}
generated quantities {
  print("In generated quantities");
}

Current Output:

Compiler does not complain.

Expected Output:

Should throw error as foo(v) is not followed by semi-colon.

Current Version:

v2.18.0

@bob-carpenter
Copy link
Contributor

Yes, definitely a bug. The handling of semicolons is a mess in general.

@VMatthijs
Copy link
Member Author

Note that rstanarm is exploiting this, currently.

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 14, 2018 via email

@mitzimorris mitzimorris modified the milestones: 2.18.1, 2.18.1++ Dec 23, 2018
@seantalts seantalts modified the milestones: 2.18.1++, 2.19.0++ Mar 20, 2019
@mcol
Copy link
Contributor

mcol commented Feb 22, 2020

Now stanc3 will not compile the example in the description:

Syntax error in 'test.stan', line 16, column 2 to column 8, parsing error:
   -------------------------------------------------
    14:    real v;
    15:    print("In transformed parameters");
    16:    foo(v)
                 ^
    17:  }
    18:  model {
   -------------------------------------------------

Ill-formed phrase. Found expression. There are many options to continue the phrase after this: "~", "[", "]" or an infix or postfix operator.

@mcol mcol closed this as completed Feb 22, 2020
@mcol mcol modified the milestones: 2.22.0++, 2.22.0 Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants