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

feat: mod.nr entrypoint #5039

Merged
merged 51 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0af1f6f
wip
michaeljklein May 16, 2024
0a682aa
feat: add skip_prelude hidden cli option, skip inject_prelude when true
michaeljklein May 16, 2024
0f682a3
cargo fmt / clippy
michaeljklein May 16, 2024
a5c4c90
add missing parameter
michaeljklein May 16, 2024
ea02811
wip debugging
michaeljklein May 16, 2024
8ef80ae
Merge branch 'michaeljklein/no-stdlib-cli' into michaeljklein/mod-nr-…
michaeljklein May 16, 2024
fd76bd8
wip debugging: find_module doesn't appear to get called for import?
michaeljklein May 16, 2024
e35a630
debugging (def maps)
michaeljklein May 16, 2024
f214832
wip debugging
michaeljklein May 16, 2024
1acbca1
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
michaeljklein Jun 10, 2024
fa75c8b
debugging cleanup
michaeljklein Jun 10, 2024
414e765
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
michaeljklein Jun 10, 2024
ef4b60c
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
TomAFrench Jun 11, 2024
3357176
chore: fmt
TomAFrench Jun 11, 2024
8407360
chore: fix compilation
TomAFrench Jun 11, 2024
c48932f
add missing "mod foo;" declarations: tests passing
michaeljklein Jun 11, 2024
3ff4884
nargo fmt, add error for overlapping paths, restrict 'main' in path, …
michaeljklein Jun 11, 2024
e6dbe62
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
michaeljklein Jun 20, 2024
98cc4dd
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
TomAFrench Jun 25, 2024
239ecc1
Update compiler/fm/src/file_map.rs
michaeljklein Jun 27, 2024
ccd8576
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
michaeljklein Jun 27, 2024
5acff7f
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
asterite Jun 28, 2024
71ed978
Make things compile again
asterite Jun 28, 2024
0f565f1
Remove the `skip_prelude` option
asterite Jun 28, 2024
d99d7f1
No need for name_to_id to be pub
asterite Jun 28, 2024
ff6f7e0
Pass reference to Ident, only clone when needed
asterite Jun 28, 2024
5559bc9
No need to create files when dealing with FileManager
asterite Jun 28, 2024
e13f443
Simplify tests a bit
asterite Jun 28, 2024
70e880f
Add a few more tests, and fix the overlapping_lib_and_mod program tha…
asterite Jun 28, 2024
80291e2
Remove maybe wrong compile failure case
asterite Jun 28, 2024
e1601bb
More tests and some code cleanup
asterite Jun 28, 2024
032e973
Undo unrelated changes
asterite Jun 28, 2024
7232716
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
asterite Jun 28, 2024
8e86139
Get the logic right
asterite Jun 28, 2024
7dfb94d
Simplify a bit more
asterite Jun 28, 2024
4046586
clippy
asterite Jun 28, 2024
bb5e890
Document `mod.nr`
asterite Jul 1, 2024
b60b49c
chore: shorten test names
TomAFrench Jul 1, 2024
a71f6e5
Delete test_programs/compile_failure/invalid_mod_mod_path/Prover.toml
TomAFrench Jul 1, 2024
9bf5a0e
Delete test_programs/compile_failure/overlapping_mod/Prover.toml
TomAFrench Jul 1, 2024
461a724
Delete test_programs/compile_success_empty/mod_nr_entrypoint/Prover.toml
TomAFrench Jul 1, 2024
9a5c713
Delete test_programs/compile_failure/invalid_main_sub_lib/Prover.toml
TomAFrench Jul 1, 2024
dff7ade
chore: add failing test case
TomAFrench Jul 1, 2024
454daa9
Update compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
TomAFrench Jul 1, 2024
46712a1
chore: rename tests
TomAFrench Jul 1, 2024
d94ace3
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
asterite Jul 1, 2024
621bdf5
Restore program that fails to compile
asterite Jul 1, 2024
9656af7
Tests that are easier to write and read
asterite Jul 1, 2024
7665a5b
Merge match branches
asterite Jul 1, 2024
254a967
clippy
asterite Jul 1, 2024
d98751e
clippy
asterite Jul 1, 2024
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
2 changes: 0 additions & 2 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion compiler/fm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ codespan-reporting.workspace = true
serde.workspace = true

[dev-dependencies]
tempfile.workspace = true
iter-extended.workspace = true
47 changes: 18 additions & 29 deletions compiler/fm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,17 @@ mod path_normalization {
#[cfg(test)]
mod tests {
use super::*;
use tempfile::{tempdir, TempDir};

// Returns the absolute path to the file
fn create_dummy_file(dir: &TempDir, file_name: &Path) -> PathBuf {
let file_path = dir.path().join(file_name);
let _file = std::fs::File::create(&file_path).unwrap();
file_path
fn add_file(fm: &mut FileManager, file_name: &Path) -> FileId {
fm.add_file_with_source(file_name, "fn foo() {}".to_string()).unwrap()
}

#[test]
fn path_resolve_file_module_other_ext() {
let dir = tempdir().unwrap();
let file_name = Path::new("foo.nr");
create_dummy_file(&dir, file_name);
let dir = PathBuf::new();
let mut fm = FileManager::new(&dir);

let mut fm = FileManager::new(dir.path());

let file_id = fm.add_file_with_source(file_name, "fn foo() {}".to_string()).unwrap();
let file_id = add_file(&mut fm, &dir.join("foo.nr"));

assert!(fm.path(file_id).unwrap().ends_with("foo.nr"));
}
Expand All @@ -213,23 +206,19 @@ mod tests {
/// they should both resolve to ../foo.nr
#[test]
fn path_resolve_modules_with_different_paths_as_same_file() {
let dir = tempdir().unwrap();
let sub_dir = TempDir::new_in(&dir).unwrap();
let sub_sub_dir = TempDir::new_in(&sub_dir).unwrap();

let mut fm = FileManager::new(dir.path());

// Create a lib.nr file at the root.
let file_name = Path::new("lib.nr");
create_dummy_file(&dir, file_name);

// Create another path with `./` and `../` inside it
let second_file_name = PathBuf::from(sub_sub_dir.path()).join("./../../lib.nr");

// Add both files to the file manager
let file_id = fm.add_file_with_source(file_name, "fn foo() {}".to_string()).unwrap();
let second_file_id =
fm.add_file_with_source(&second_file_name, "fn foo() {}".to_string()).unwrap();
let dir = PathBuf::new();
let mut fm = FileManager::new(&dir);

// Create a lib.nr file at the root and add it to the file manager.
let file_id = add_file(&mut fm, &dir.join("lib.nr"));

// Create another path with `./` and `../` inside it, and add it to the file manager
let sub_dir = dir.join("sub_dir");
let sub_sub_dir = sub_dir.join("sub_sub_dir");
let second_file_id = add_file(
&mut fm,
PathBuf::from(sub_sub_dir.as_path()).join("./../../lib.nr").as_path(),
);

assert_eq!(file_id, second_file_id);
}
Expand Down
1 change: 0 additions & 1 deletion compiler/noirc_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ lalrpop-util = { version = "0.20.2", features = ["lexer"] }
base64.workspace = true
strum = "0.24"
strum_macros = "0.24"
tempfile.workspace = true

[build-dependencies]
lalrpop = "0.20.2"
Expand Down
Loading
Loading