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

Term printer error #1147

Closed
msaaltink opened this issue Mar 23, 2021 · 3 comments · Fixed by #1286
Closed

Term printer error #1147

msaaltink opened this issue Mar 23, 2021 · 3 comments · Fixed by #1286
Assignees
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem type: bug Issues reporting bugs or unexpected/unwanted behavior

Comments

@msaaltink
Copy link
Contributor

It is somewhat perplexing that these two expressions, with different types and structure, print almost exactly the same:

sawscript> {{ \ (x:Integer) -> [(x,x)] }}
[19:23:38.879] \(x : Prelude.Integer) -> [x,x]
sawscript> {{ \ (x:Integer) -> [x,x] }}
[19:23:49.800] \(x : Prelude.Integer) -> [x, x]

What happened to the parentheses around the tuple?

A very careful reader could check for whitespace after a comma to distinguish these two, but that's an easily missed distinction.

@brianhuffman brianhuffman added type: bug Issues reporting bugs or unexpected/unwanted behavior subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem labels Mar 29, 2021
@brianhuffman
Copy link
Contributor

This is probably just a mistake in the use of precedence levels in the saw-core pretty printer.

@msaaltink
Copy link
Contributor Author

I occasionally see this in the let-binding list, but it seems hard to reproduce in a small example. Seen recently, in a large formula

x@44 = x@37,x@38,x@23

Not too bad here, but in another case there are line breaks coupled with an ill-chosen left margin:

  x@63 = x@60,
  [email protected] ([email protected] ([email protected] (x@59,x@60),x@55),[email protected] (x@62,x@62)),
  [email protected] ([email protected] (x@21,x@21),x@48)

To be sure, though, putting the parentheses in and indenting properly will do little to improve the readability of that!

@robdockins
Copy link
Contributor

I bumped into this recently. I think the problem is here:

https://github.com/GaloisInc/saw-core/blob/ea914a9eea8e484189ee6e4c4dcdfc7db831d987/saw-core/src/Verifier/SAW/Term/Pretty.hs#L349

There should probably be a precendence level between None and whatever is next that corresponds to constructing the right-tail of a compound tuple so we don't forget to put the outermost parens around a tuple.

@brianhuffman brianhuffman self-assigned this May 4, 2021
brianhuffman pushed a commit that referenced this issue May 4, 2021
This lets us print pair values using infix ',' with parens in the
right places.

Fixes #1147.
brianhuffman pushed a commit that referenced this issue May 4, 2021
This lets us print pair values using infix ',' with parens in the
right places.

Fixes #1147.
brianhuffman pushed a commit that referenced this issue May 5, 2021
This lets us print pair values using infix ',' with parens in the
right places.

Fixes #1147.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants