Skip to content

frontend: wrong prettyPrint for unary operators #239

Closed
@AndreasKrall

Description

@AndreasKrall

--expand-macros (prettyPrint) gives wrong output for unary operators as the required parentheses are removed resulting in wrong not parseable pretty printed specification. Both the untyped and typed ASTs are correct. The following example shows the original correct test input:

function A -> Bits<32> =  -4 as Bits<32>
function B -> Bits<32> = -(4 as Bits<32>)
function C -> Bits<32> = ~(3 as Bits<32>)
function D -> Bool     = !(3 as Bool)

Here is the wrong prettyPrint output where the parentheses are missing:

function A -> Bits<32> = -4 as Bits<32>
function B -> Bits<32> = -4 as Bits<32>
function C -> Bits<32> = ~3 as Bits<32>
function D -> Bool = !3 as Bool

The output for A is correct, all the others are wrong.
The code in Expr.java in lines 462 to 468 is wrong.
The following must be deleted (and the closing }:

    if (operator instanceof UnOp) {
      operand.prettyPrint(indent, builder);
    } else {

Please fix that soon, I need to check the AArch64 spec.Expr.java is easy, the tests could be some work.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfrontendThis is frontend related

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions