Skip to content

[JsLIGO] Removal of automatic insertion of vertical bars in type expressions

Christian Rinderknecht requested to merge rinderknecht@vbar into dev

Motivation and Context

Description

In order to avoid a shift/reduce in the parser of JsLIGO, a heuristic was used (as a self-pass on the tokens) to inject vertical bars in front of what looks like a variant type expression. Unfortunately, the heuristic is not complete and the pretty-printer does not output leading vertical bars and the result sometimes fail to parse (as the heuristic is incomplete and fails to insert a bar).

The heart of the LR conflict is this. A string is allowed as a type to guide the compilation to Michelson, for instance, with sapling or layout. The case ["C"] creates a shift/reduce conflict because the LR algorithm cannot distinguish a variant type with a constant constructor C from a type tuple (that is, an array of type expressions) containing the special type "C".

In this MR, we propose to remove the heuristic and forbid the first component of a type tuple to be a string. While this is in theory a breaking change, the uses of those types (sapling, layout) rely on a string as a type after another component type, therefore not as the first component in a tuple (array).

Component

  • 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)

Changelog

Checklist:

  • 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 Melwyn Saldanha

Merge request reports