sweet-js/sweet-core

modules can be `invoke`d too many times

disnet opened this issue · 0 comments

A module imported for syntax is currently re-invoked for each module that imports it.

For example, given some modules like:

// lib.js
export const x = 1;

// mod.js
import { x } from './lib' for syntax;

export syntax m = ctx => {
  x;
  return #`1`;
}

// main.js
import { x } from './lib' for syntax;
import { m } from './mod';

syntax n = ctx => {
  x;
  return #`2`;
}

we get an error:

evalmachine.<anonymous>:1
const x_1 = 1;
^

SyntaxError: Identifier 'x_1' has already been declared

/cc @gabejohnson I think this is the root cause of the error you mentioned the other day.