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

bug: LS should not autocomplete private re-exports + scarb build should not succeed when a private export is imported #5859

Closed
2 tasks
0xNeshi opened this issue Jun 24, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@0xNeshi
Copy link

0xNeshi commented Jun 24, 2024

Bug Report

Cairo version:

scarb 2.6.4+nightly-2024-06-22 (5deb60ac1 2024-06-22)
cairo: 2.6.4 (f3af4cb8d)
sierra: 1.5.0

Current behavior:

Compiler complains that "Item core::starknet::deploy_syscall is not visible in this context." in a test module, even though it one of the recommended imports by the LSP.
image

Running scarb build in the terminal runs successfully despite this error.

Running scarb cairo-test in the terminal fails with the "deploy_syscall is not visible in this context" error!

Expected behavior:

Either:

  • the language server should not list private re-exports, like deploy_syscall in the autocomplete dialog
  • scarb build should fail when a private re-export is imported in a module

Steps to reproduce:

  • create new Cairo project
  • open Scarb.toml and add:
[dependencies]
starknet = ">=2.6.3"

[dev-dependencies]
cairo_test = "2.6.4+nightly-2024-06-22"
  • open lib.cairo, delete the contents and paste just the following:
#[cfg(test)]
mod tests {
    use starknet::deploy_syscall;
}
@0xNeshi 0xNeshi added the bug Something isn't working label Jun 24, 2024
@0xNeshi 0xNeshi changed the title bug: VS Code Extension doesn't recognize that deploy_syscall is visible in a test module bug: compiler doesn't recognize that deploy_syscall is visible in a test module Jun 24, 2024
@mexes20
Copy link

mexes20 commented Jun 24, 2024

@misicnenad can I be assined this?

@mkaput mkaput assigned mexes20 and unassigned mexes20 Jun 24, 2024
@mkaput
Copy link
Contributor

mkaput commented Jun 24, 2024

@misicnenad I think you should import the following path instead:

use starknet::syscalls::deploy_syscall;

If this is the fix for you, then the problem is LS which autocompletes private re-exports. If you confirm, then I'll re-phrase the issue.

@0xNeshi
Copy link
Author

0xNeshi commented Jun 24, 2024

@mkaput the issue I was describing is exactly this:

then the problem is LS which autocompletes private re-exports

Maybe I should re-phrase the description.

Another related issue is that running scarb build succeeds, even though this should not build.

EDIT: I used a confusing description for the issue. Rephrased it to more accurately describe the problem.

Note: I'm aware that use starknet::syscalls::deploy_syscall; is the correct import path.

@0xNeshi 0xNeshi changed the title bug: compiler doesn't recognize that deploy_syscall is visible in a test module bug: LS should not autocomplete private re-exports + scarb build should not succeed when a private export is imported Jun 24, 2024
@0xNeshi
Copy link
Author

0xNeshi commented Jun 25, 2024

@mkaput I just remembered that I'd already opened a similar issue to disable recommending private exports, see #5660.

Can we then close this issue?

@mkaput
Copy link
Contributor

mkaput commented Jun 25, 2024

yes indeed

@mkaput mkaput closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
@maciektr
Copy link
Collaborator

Another related issue is that running scarb build succeeds, even though this should not build.

scarb build does not compile tests. All items under cfg(test) are discarded on the syntactic level. This means, that when compiler gets to the part when it resolves your uses to see if they exists (and thus can emit errors) - it's already removed.

To build tests, you can run scarb build --test (or similarly scarb check --test), which scarb test does under the hood. This will produce the errors.

CC @misicnenad

@0xNeshi
Copy link
Author

0xNeshi commented Jun 25, 2024

@maciektr that actually makes a lot of sense. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants