Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/noirc_frontend/src/elaborator/path_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ impl Elaborator<'_> {
});
}

let plain_or_crate = matches!(path.kind, PathKind::Plain | PathKind::Crate);
let first_segment_is_always_visible = match path.kind {
PathKind::Crate => true,
PathKind::Plain => importing_module == starting_module,
PathKind::Dep | PathKind::Super | PathKind::Resolved(_) => false,
};

// The current module and module ID as we resolve path segments
let mut current_module_id = starting_module;
Expand Down Expand Up @@ -551,7 +555,7 @@ impl Elaborator<'_> {

// If the path is plain or crate, the first segment will always refer to
// something that's visible from the current module.
if !((plain_or_crate && index == 0)
if !((first_segment_is_always_visible && index == 0)
|| item_in_module_is_visible(
self.def_maps,
importing_module,
Expand Down
10 changes: 6 additions & 4 deletions compiler/noirc_frontend/src/hir/resolution/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ impl<'def_maps, 'usage_tracker, 'references_tracker>
});
}

let plain_or_crate = matches!(path.kind, PathKind::Plain | PathKind::Crate);
let first_segment_is_always_visible = match path.kind {
PathKind::Crate => true,
PathKind::Plain => self.importing_module == starting_module,
PathKind::Dep | PathKind::Super | PathKind::Resolved(_) => false,
};

// The current module and module ID as we resolve path segments
let mut current_module_id = starting_module;
Expand Down Expand Up @@ -375,9 +379,7 @@ impl<'def_maps, 'usage_tracker, 'references_tracker>
ModuleDefId::GlobalId(_) => panic!("globals cannot be in the type namespace"),
};

// If the path is plain or crate, the first segment will always refer to
// something that's visible from the current module.
if !((plain_or_crate && index == 0)
if !((first_segment_is_always_visible && index == 0)
|| self.item_in_module_is_visible(current_module_id, visibility))
{
errors.push(PathResolutionError::Private(last_ident.clone()));
Expand Down
2 changes: 1 addition & 1 deletion test_programs/benchmarks/semaphore_depth_10/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ type = "bin"
authors = [""]

[dependencies]
ec = { git = "https://github.com/noir-lang/noir-edwards", tag = "v0.2.4" }
ec = { git = "https://github.com/noir-lang/noir-edwards", tag = "v0.2.5" }
poseidon = { git = "https://github.com/noir-lang/poseidon", tag = "v0.1.1" }
6 changes: 3 additions & 3 deletions test_programs/benchmarks/semaphore_depth_10/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

use ec::bjj::BabyJubJubParams;
use ec::{Curve, CurveTrait};
use ec::scalar_field::ScalarField;
use std::field::bn254::assert_lt;
use ec::ScalarField;
use poseidon::poseidon::bn254::hash_2 as poseidon;
use std::field::bn254::assert_lt;

// The maximum depth of the Merkle Tree the inclusion proof will be coming from.
// This value can get updated by overwriting this line.
Expand Down Expand Up @@ -83,4 +83,4 @@ fn main(

// Return the calculated Merkle tree root & nullifier
(node, nullifier)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "access_private_dependency_item"
type = "bin"
authors = [""]
compiler_version = ">=0.33.0"

[dependencies]
foo = { path = "./foo" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "foo"
type = "lib"
authors = [""]
compiler_version = ">=0.31.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod bar {
pub fn baz() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use foo::bar::baz;

fn main() {
foo::bar::baz();
baz();
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading