Skip to content

File import: make `export` mandatory to export values/types/namespaces when importing modules from other files

E. Rivas requested to merge er433/fix/private-include into dev

Motivation and Context

Related Issue: #2003 (closed) .

Description

We make type-checking with signature filter only exported values.

As this is a breaking change, our libraries should be checked after this change.

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

When importing a file with #import, every definition was imported, even those not marked with export explicitly in JsLIGO, e.g. in previous versions we had:

$ ligo compile expression jsligo y --init-file modules_export_importer.jsligo
42

$ cat modules_export_imported.jsligo 
type t = int;

const x : t = 42;
$ cat modules_export_importer.jsligo 
#import "modules_export_imported.jsligo" "M"

const y : M.t = M.x;

After this change, export is needed in JsLIGO to effectively export a declaration:

$ ligo compile expression jsligo y --init-file modules_export_importer.jsligo     
File "modules_export_importer.jsligo", line 3, characters 10-13:
  2 | 
  3 | const y : M.t = M.x;

Type "t" not found. 

The same applies for CameLIGO: after this change, declarations marked with @private are not exported.

Checklist:

  • 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 E. Rivas

Merge request reports

Loading