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

LSP: Cannot resolve local dependencies outside of the main file #1838

Closed
Tracked by #1558
phated opened this issue Jun 29, 2023 · 0 comments
Closed
Tracked by #1558

LSP: Cannot resolve local dependencies outside of the main file #1838

phated opened this issue Jun 29, 2023 · 0 comments
Assignees
Labels
bug Something isn't working lsp Language Server Protocol

Comments

@phated
Copy link
Contributor

phated commented Jun 29, 2023

Aim

The LSP should work with local dependencies in files other than the main.nr file.

Expected Behavior

When I create a file, such as foo.nr with this content:

use crate::bar::bar;

fn foo(x : Field, y : Field) {
    bar(x, y);
}

The dependency should not be a compile error.

Bug

This bug stems from the fact that we compile the saved file (foo.nr in the example above) as the root of the project. Since the root file is expected to contain the mod definitions, but those are all specified in main.nr, the LSP compilation reports an error because there was no mod bar.

Side note: adding mod bar makes the file compile with no warnings via the LSP but nargo compile would fail because it is not actually the root.

To Reproduce

  1. Create a multi-file noir project
  2. Use a crate:: dependency in a file that is not main.nr
  3. Save the file with the LSP running
  4. Notice the diagnostic warning on the dependency

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@phated phated added bug Something isn't working lsp Language Server Protocol labels Jun 29, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jun 29, 2023
ludamad added a commit that referenced this issue Jul 5, 2023
This is currently not ideal in form but should inform a larger fix
github-merge-queue bot pushed a commit that referenced this issue Jul 13, 2023
* fix: workaround for #1838

This is currently not ideal in form but should inform a larger fix

* fix: cargo check

* Fix hacked path

* Fix hacked path

* Fix hacked path

* feat: make array indexes polymophic integers (#1877)

* feat: make array indexes poly int

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

* Update crates/noirc_frontend/src/hir/type_check/stmt.rs

---------

Co-authored-by: jfecher <jake@aztecprotocol.com>

* Make proving and verification keys optional

* More merge progress

* chore: introduce lib_hacky segregation

---------

Co-authored-by: Álvaro Rodríguez <sirasistant@gmail.com>
Co-authored-by: jfecher <jake@aztecprotocol.com>
Co-authored-by: kevaundray <kevtheappdev@gmail.com>
@kobyhallx kobyhallx moved this from 📋 Backlog to 🏗 In progress in Noir Aug 8, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Noir Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lsp Language Server Protocol
Projects
Archived in project
Development

No branches or pull requests

2 participants