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

Scoper crashes on symbol from imported nested local module #2654

Closed
paulcadman opened this issue Feb 16, 2024 · 0 comments · Fixed by #2655
Closed

Scoper crashes on symbol from imported nested local module #2654

paulcadman opened this issue Feb 16, 2024 · 0 comments · Fixed by #2655

Comments

@paulcadman
Copy link
Collaborator

See https://github.com/anoma/juvix/tree/nested-local-module-bug for the test case demonstrating this bug

Say you have a module containing nested local modules:

module ImportNestedLocalModule;

import Stdlib.Prelude open;

module A;

  module B;
     x : Nat := 1;
  end;

end;

Run juvix dev scope on the following module:

module test074;

import Stdlib.Prelude open;
import ImportNestedLocalModule open;

main : Nat := ImportNestedLocalModule.A.B.x;

This module is expected to scope check. However the scoper crashes with the following error:

juvix: impossible. Could not find local module B defined at /Users/paul/heliax/juvix-2024/tests/Compilation/positive/test074/ImportNestedLocalModule.juvix:7:10-11
Modules in the state: [Nat@Juvix.Builtin.V1.Nat.Base:4, Integral@Stdlib.Trait.Integral:6, ImportNestedLocalModule@ImportNestedLocalModule:0, Eq@Stdlib.Trait.Eq:4, ×@Stdlib.Data.Product.Base:3, Natural@Juvix.Builtin.V1.Trait.Natural:8, Show@Stdlib.Trait.Show:4, Int@Stdlib.Data.Int.Base:4, Ordering@Stdlib.Trait.Ord:5, A@ImportNestedLocalModule:3, Bool@Juvix.Builtin.V1.Bool:4, Maybe@Juvix.Builtin.V1.Maybe:4, Partial@Stdlib.Trait.Partial:4, Ord@Stdlib.Trait.Ord:13, Unit@Stdlib.Data.Unit:3, Stdlib.Prelude@Stdlib.Prelude:0, List@Juvix.Builtin.V1.List:4]
CallStack (from HasCallStack):
  error, called at src/Juvix/Prelude/Base.hs:402:9 in juvix-0.5.5-86FKWMdO6cV1eCQIhkrrGY:Juvix.Prelude.Base
  error, called at src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping.hs:453:7 in juvix-0.5.5-86FKWMdO6cV1eCQIhkrrGY:Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping
paulcadman added a commit that referenced this issue Feb 16, 2024
This PR fixes a TODO in the scoper code. We need to transitively
register local modules when checking an import.


* Closes #2654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant