esverify icon indicating copy to clipboard operation
esverify copied to clipboard

Comment annotations

Open nono opened this issue 7 years ago • 1 comments

Hello,

esverify looks nice. I think it may be more practical for existing projects to put the ensures and requires annotations in comments, to avoid any side-effect during the execution. You may be inspired by the comment types of Flow: https://flow.org/en/docs/types/comments/.

The example in the README could look like this:

function max(a, b) {
  /*-@
  requires(typeof a === "number");
  requires(typeof b === "number");
  ensures(res => res >= a);
  */

  if (a >= b) {
    return a;
  } else {
    return b;
  }
}

nono avatar Dec 03 '18 07:12 nono

It might be possible to add a flag/option to enable parsing comments that include pre-, postconditions, etc. Currently, "requires", "ensures", etc. are pseudo-function calls that are already exempt from execution and essentially serve as comments with better syntax highlighting and variable scoping.

levjj avatar Jul 20 '19 22:07 levjj