Skip to content

Commit

Permalink
Merge pull request #108 from Chia-Network/20240713-bin-quote
Browse files Browse the repository at this point in the history
Fix accidental parsing of processed inputs for dependency analysis and add a test
  • Loading branch information
prozacchiwawa authored Jul 17, 2024
2 parents a2f66ba + aebb21e commit 6ed6ee8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/tests/bin-quote.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'test
3 changes: 2 additions & 1 deletion src/compiler/preprocessor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ impl Preprocessor {
desc: IncludeDesc,
) -> Result<(), CompileErr> {
let name_string = decode_string(&desc.name);
if KNOWN_DIALECTS.contains_key(&name_string) {
// Terminate early checking anything with a processed include type.
if KNOWN_DIALECTS.contains_key(&name_string) || desc.kind.is_some() {
return Ok(());
}

Expand Down
13 changes: 13 additions & 0 deletions src/tests/classic/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2495,3 +2495,16 @@ fn test_include_zero_bin_pre_fix() {
]);
assert_eq!(program, "(2 (1 14 (1 . 1) 2) (4 (1 . 1) 1))");
}

#[test]
fn test_include_bin_should_not_be_parsed() {
let program = do_basic_run(&vec![
"run".to_string(),
"-i".to_string(),
"resources/tests".to_string(),
"(mod (X) (include *standard-cl-23.1*) (embed-file test bin bin-quote.bin) test)"
.to_string(),
]);
let result = do_basic_brun(&vec!["brun".to_string(), program]);
assert_eq!(result.trim(), "\"'test\"");
}

0 comments on commit 6ed6ee8

Please sign in to comment.