'Pedantic Mode' Wishlist

I don’t think pedantic mode should be on by default. It’s already caused us no end of pain with just the false positives from the Jacobian warnings.

I feel many people won’t mind the additional safety net, even if it is somewhat annoying, but the users most likely to benefit from it are also least likely to react here.

In the long run, it would IMHO be best to have pedantic mode on by default (because novice users are unlikely to know that it exists) and have annotations to ignore specific warnings at specific places to make it easy to include less standard stuff without being constantly reminded of it e.g.:

x ~ normal(0, 2);
//[nowarn: double-use, jacobian] This adjustment follows from formula 10.3 of Foo&Bar 2022
sum(exp(x)) ~ normal (0, 0.1);

But I understand this is likely a lot of work

2 Likes

Yup.

I like to consider what other mature languages do when deciding things like this. Here’s a C++ program with a bug:

int main() {
  int a;
  std::cout << a << std::endl;
}

and here’s clang++:

$ clang++ foo.cpp
$

No warnings. Now here’s what happens when I ask for it to turn all the warnings on:

$ clang++ -Wall foo.cpp
foo.cpp:8:16: warning: variable 'a' is uninitialized when used here [-Wuninitialized]
  std::cout << a << std::endl;
               ^
foo.cpp:7:8: note: initialize the variable 'a' to silence this warning
  int a;
       ^
        = 0
1 warning generated.
$

Overall, the warnings available from clang++ are minimal. Stylistic and semantic suggestions go into standalone programs like clang format and cpplint.

Also, the C++ compiler warnings are very precise. Anything we leave on has to have very few, if any, false positives. I think adding the Jacobian warnings as we’ve done was a mistake, for example.

1 Like

I’ve just posted about a prototype implementation of Pedantic Mode here

3 Likes