Skip to content

Commit 14cd6dc

Browse files
committed
fix #118
1 parent 7270b6a commit 14cd6dc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

crates/lean_compiler/src/parser/parsers/program.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ impl Parse<Program> for ProgramParser {
5353
let saved_file_id = ctx.current_file_id;
5454
ctx.current_filepath = filepath.clone();
5555
ctx.imported_filepaths.insert(filepath.clone());
56-
let file_id = ctx.get_next_file_id();
57-
ctx.current_file_id = file_id;
58-
filepaths.insert(file_id, filepath.clone());
59-
ctx.current_source_code = ProgramSource::Filepath(filepath).get_content(&ctx.flags).unwrap();
60-
source_code.insert(file_id, ctx.current_source_code.clone());
56+
ctx.current_source_code = ProgramSource::Filepath(filepath.clone())
57+
.get_content(&ctx.flags)
58+
.unwrap();
6159
let subprogram = parse_program_helper(ctx)?;
6260
functions.extend(subprogram.functions);
6361
function_locations.extend(subprogram.function_locations);

crates/lean_compiler/tests/test_compiler.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,3 +1322,13 @@ fn test_const_array_element_exponentiation() {
13221322
false,
13231323
);
13241324
}
1325+
1326+
#[test]
1327+
fn test_num_files() {
1328+
let expected_num_files = 3; // program_6.snark imports foo.snark and bar.snark
1329+
let manifest_dir = env!("CARGO_MANIFEST_DIR");
1330+
let path = format!("{manifest_dir}/tests/program_6.snark");
1331+
let bytecode = compile_program(&ProgramSource::Filepath(path));
1332+
assert_eq!(bytecode.filepaths.len(), expected_num_files);
1333+
assert_eq!(bytecode.source_code.len(), expected_num_files);
1334+
}

0 commit comments

Comments
 (0)