question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistency in placement of comments as returned by OpDefOrDeclNode.getComment

See original GitHub issue

We are now using OpDefOrDeclNode.getComment to parse annotations in TLA+ declarations, see this PR. While it works well, we have noticed a few inconsistencies in the placement of comments. For instance, in the recursive definitions, a comment has to be placed between RECURSIVE ... and the definition, whereas in the local definitions, a comment has to be placed in front of LOCAL.

Below you can find an example of how annotations should be placed in front of declarations. It would be great, if SANY was using a more consistent scheme for getComment.

-------- MODULE Annotations ----------
EXTENDS Integers

CONSTANT
  \* @type: Int;
  N

VARIABLE
  \* @type: Set(Int);
  set

\* @pure
\* @type: Int => Int;
Inc(n) == n + 1

\* @type: Int => Int;
LOCAL LocalInc(x) == x + 1

A(n) ==
  LET \* @pure
      \* @type: Int => Int;
      Dec(x) == x + 1
  IN
  Dec(n)

RECURSIVE Fact(_)
\* @tailrec
\* @type: Int => Int;
Fact(n) ==
  IF n <= 1 THEN 1 ELSE n * Fact(n - 1)

\* @tailrec
\* @type: Int -> Int;
FactFun[n \in Int] ==
  IF n <= 1 THEN 1 ELSE n * FactFun[n - 1]

======================================

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
lemmycommented, Feb 6, 2021

FWIW: Annotations appear to be an interesting alternative to the config file. Especially, when combined with multi-module .tla files:

spec.tla

---- MODULE spec ----
\* @Const(42)
CONSTANT N

VARIABLE v

Init == v = N

Next == v = v'

\* @BehaviorSpec
Spec == Init /\ [][Next]_v

\* @Invariant
Inv == v = 42

====

model.tla

---- MODULE model ----
VARIABLE v

INSTANCE spec WITH N <- 42

\* @StateContraint
StateConstraint == v = 42
====
1reaction
lemmycommented, Feb 11, 2021

Why do we have to care about the JLS? Anyway, make it “@apalache_type”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tlaplus - Bountysource
Inconsistency in placement of comments as returned by OpDefOrDeclNode.getComment $ 0 ... getComment to parse annotations in TLA+ declarations, see this PR.
Read more >
How to easily extract comments contents in Excel?
Save the code and go back to the sheet you want to extract comment contents, type =getComment(B2) in a cell which will place...
Read more >
Insert comments and notes in Excel - Microsoft Support
Insert threaded comments for discussions · Right-click the cell and then click New Comment. · Type your comment. · Click the Post button...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found