Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't have two modules with the same filename #298

Open
IsaacOscar opened this issue Jun 16, 2019 · 2 comments
Open

Can't have two modules with the same filename #298

IsaacOscar opened this issue Jun 16, 2019 · 2 comments
Labels

Comments

@IsaacOscar
Copy link
Contributor

When I have two files, foo.grace:

import "folder/foo" as F
F.hello

And folder/foo.grace:

method hello { print("hello") }

It fails to compile on master (due to issue #295), but compiles on the branch for pull request #297.

However it causes a stack overflow at runtime:

RequestError: error on line 1 of module foo: Maximum call stack size exceeded
  raised at module initialization at line 1 of folder/foo
  requested from module initialization at line 1 of folder/foo
  ...

Change either of the file names fixes the issue.

@apblack
Copy link
Contributor

apblack commented Jun 17, 2019

Yes, this has to do with the way that the compiled code references modules. It's good to register it as an issue.

@apblack
Copy link
Contributor

apblack commented Sep 9, 2019

I flagged this as wontfix because allowing multiple modules with the same name would require a significant re-work of the way that the compiled code functions are named. At present, they are named gracecode_‹moduleName›. A possible fix would be to name them gracecode_‹moduleSHA›, where moduleSHA is a cryptographically-secure digest of the module source.

apblack added a commit that referenced this issue Sep 9, 2019
Submodules are imported with paths relative to
the importing module.  This fix allows the compiler
to find the compiled code when it is created in the
same folder as the source.  The change is to index the
gct cache by module name, rather than path name.
This means that it is impossible to import two modules
with the same name, but that restriction is also imposed
by the gracecode_‹modulename› naming convention for compiled
code (#298).
apblack added a commit that referenced this issue Sep 10, 2019
Submodules are imported with paths relative to
the importing module.  This fix allows the compiler
to find the compiled code when it is created in the
same folder as the source.  The change is to index the
gct cache by module name, rather than path name.
This means that it is impossible to import two modules
with the same name, but that restriction is also imposed
by the gracecode_‹modulename› naming convention for compiled
code (#298).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants