Skip to content

Fix `#include` for jsligo due to missing case in ASI

Melwyn Saldanha requested to merge fix/semi_colon_before_directive into dev

Motivation and Context

a.jsligo

const x = 1

const y = x + 1

b.jsligo

#include "a.jsligo"

const z = x + y

const test = assert (z == 3)

When a .jsligo file is #included in another LIGO file and the last declaration in the .jsligo is not terminated by a ; (semi-colon)

we get weird errror like ("Simple_utils__Region.Different_files(\"a.jsligo\", \"b.jsligo\")").

By fixing the ASI the error goes away

Description

This MR handle the missing cases in Automatic Semicolon Inserstion for Directive

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

Fixes bug in #including jsligo files when semicolon is missing the last declaration of included file

Before:

$ ligo.54 run test b.jsligo
An internal error ocurred. Please, contact the developers.
("Simple_utils__Region.Different_files(\"b.jsligo\", \"a.jsligo\")").

After:

$ ligo run test b.jsligo
Everything at the top-level was executed.
- test exited with value ().

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).
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Melwyn Saldanha

Merge request reports