jow- / ucode

JavaScript-like language with optional templating
ISC License
87 stars 24 forks source link

BUG: 2nd level import fails when using * #109

Closed huafu closed 1 year ago

huafu commented 1 year ago

When using * in imports (import * as m from './some-module.uc'), ucode would throw Runtime error: unknown opcode 0.

To reproduce:

  1. create file level2.uc:
    // level2.uc
    function level2() {
      print('Hello\n');
    }
    export { level2 };
  2. create file level1.uc:
    // level1.uc
    import { level2 } from './level2.uc'
    function level1() {
      level2();
    }
    export { level1 };
  3. in the same directory of the files, run:
    ucode -e "import * as m from './level1.uc'; m.level1();"

    it'll fail with Runtime error: unknown opcode 0

Tho if you use named imports, or if there is only one level of imports, it'll work:

ucode -e "import { level1 } from './level1.uc'; level1();" # works!

ucode -e "import * as m from './level2.uc'; m.level2();" # works! (notice the ./level2.uc and not ./level1.uc)
jow- commented 1 year ago

This has been fixed as a side effect of https://github.com/jow-/ucode/commit/d64d5d685d86b38dda8a314b7d1404633e26b346