Skip to content

Add support for attributes before `namespace` in jsligo parser

Melwyn Saldanha requested to merge fix@jsligo_sytax_errors_asi_and_namespace into dev

Motivation and Context

This MR fixes 2 issues,

  1. Incorrect ASI when export is followed by a newline
  2. Attributes before namespace is not handled by parser

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

For a jsligo file

// @foo
export namespace D {
  export type titi = int;
};

// @foo
namespace E {
  export type titi = int;
  export const toto = 42
};

/* @no_mutation */ export
const toto: D.titi = E.toto;

Before

$ ligo.62 print cst y.jsligo 
File "y.jsligo", line 2, characters 7-16:
  1 | // @foo
  2 | export namespace D {
  3 |   export type titi = int;
Ill-formed export declaration.
At this point, a value or type declaration is expected.

After

$ ligo print cst y.jsligo 
<ast>
├ Directive (y.jsligo:1:0-14)
├ PP_Linemarker (1, "y.jsligo", None)
├ SExport (y.jsligo:2:0-4:1)
├ SNamespace (y.jsligo:2:7-4:1)
├ <namespace> (y.jsligo:2:7-16)
├ <attributes>
| └ <attribute>
|   └ private
...

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