Skip to content

Fixing pretty-printers

Christian Rinderknecht requested to merge rinderknecht@jsligo_line_comments into dev

Motivation and Context


const _ = () => {
  if (1 !=2 ) { return 1 } // foo
  else return 2

was wrongly printed as:

const _ = () => {
  if (1 != 2) {
    return 1
  } // foo else return 2

The return 2 statement was captured in the preceding line comment // foo

For CameLIGO:

let f3 =
  (fun () -> module A = Tezos in
     fun s -> + 1
   : unit -> t -> int)

was wrongly printed as:

let f3 =
  (fun () -> moduleA = Tezos in
     fun s -> + 1
   : unit -> t -> int)


For JsLIGO, the printing of trailing comments was not followed by a line break, hence the bug. But we cannot always issue a line break after a trailing comment, for example, when the comment is about a property in an object: the printing of the object already break lines, hence two line breaks could result. The solution is to bring to the function printing property separators the context and decide to break the line.

For CameLIGO, a space was simply missing after the keyword module.


  • compiler
  • website
  • webide
  • vscode-plugin
  • debugger

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)


[JsLIGO] Fixed pretty-printing of line comments within conditionals. [CameLIGO] Added a space after the keyword module in local definitions.


  • If a new syntax has been introduced, put a message on slack ligo-lsp
  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Christian Rinderknecht

Merge request reports