Jaseci-Labs / jaclang

The Jac Programming Language
https://www.jac-lang.org
22 stars 21 forks source link

Impl Imports are not present #206

Closed chandralegend closed 8 months ago

chandralegend commented 8 months ago

For example, lets assume we have test.jac and test.impl.jac

can test;
with entry {print(test());
import math;
:can:test {
    return math.sqrt(2);
}

Error

  File "/opt/conda/envs/lame-tool/bin/jac", line 8, in <module>
    sys.exit(start_cli())
             ^^^^^^^^^^^
  File "/opt/conda/envs/lame-tool/lib/python3.11/site-packages/jaclang/cli/cli.py", line 138, in start_cli
    ret = command.call(**args_dict)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/lame-tool/lib/python3.11/site-packages/jaclang/cli/cmdreg.py", line 40, in call
    return self.func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/lame-tool/lib/python3.11/site-packages/jaclang/cli/cli.py", line 52, in run
    __jac_import__(
  File "/opt/conda/envs/lame-tool/lib/python3.11/site-packages/jaclang/compiler/importer.py", line 81, in jac_import
    exec(codeobj, module.__dict__)
  File "test.jac", line 4, in <module>
    print(test());
           ^^^^^^
  File "test.jac", line 4, in test
    print(test());
            ^^^^
NameError: name 'math' is not defined

Issue - Generated AST doesn't have the math import and also no .impl.imported as well.

marsninja commented 8 months ago

Hi @chandralegend Very nice feature request. I just banged it out in 344bb82

I really like that you through in sufficient minimal code so I could run a TDD loop real quick. My TDD passes quite nicely, do test it in prod SLAM and let me know if it works there too!!!

Keep the good ideas/request coming !!