alashworth / test-issue-import

0 stars 0 forks source link

improve error msg when delcaration is made after assignment #196

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by yizhang-cae Monday May 07, 2018 at 03:31 GMT Originally opened as https://github.com/stan-dev/stan/issues/2523


Summary:

When declare after assignment the msg is not informative.

Description:

When declare after assignment the error msg is variable xxx does not exitst where xxx is the type name of the declared variable. This is not informative to beginners.

Reproducible Steps:

make a model with the following transformed data

transformed data {
  real x;
  x = 3.0;
  real z;
  z = 3.0
}

Current Output:

SYNTAX ERROR, MESSAGE(S) FROM PARSER:

variable "real" does not exist.

Expected Output:

More informative information on the order of declaration & assignment.

Current Version:

v2.17.1

alashworth commented 5 years ago

Comment by bob-carpenter Tuesday May 08, 2018 at 03:12 GMT


Thanks---the message should definitely be improved. The plan is to relax the language to allow that to be legal, but until then, there needs to be a better message.

alashworth commented 5 years ago

Comment by VMatthijs Thursday Dec 13, 2018 at 12:49 GMT


Mixing var decls and statements in any order is now allowed in stanc3, in case that addresses the issue.