Skip to content
Merged
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
58 changes: 58 additions & 0 deletions crates/ry-checker/tests/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,3 +1238,61 @@ fn removed_function_matches_cold() {

assert_eq!(incremental, cold);
}

/// Issue #90: renaming a function must invalidate the old name with the
/// replaced pass-1 entry. The old name is absent from the new function
/// table, so only the retained name seeds the reverse call graph. Without
/// it, the fixpoint keeps the previous refined return type of every
/// function that reached the old name, and transitive callers keep
/// diagnostics derived from the stale type.
#[test]
fn renamed_function_matches_cold_for_transitive_callers() {
let mut project = Project::new();
project.add_file(
"leaf.R".to_string(),
parse("leaf.R", "helper <- function() \"s\"\n"),
);
project.add_file(
"middle.R".to_string(),
parse("middle.R", "mid <- function() helper()\n"),
);
project.add_file(
"top.R".to_string(),
parse("top.R", "result <- mid() + 1L\n"),
);
let before = project.check_incremental();
let before_top = before
.iter()
.find(|(path, _)| path == "top.R")
.expect("top.R checked");
assert!(
before_top
.1
.iter()
.any(|diagnostic| diagnostic.code == "RY040"),
"the character return should reach the transitive caller: {before_top:?}",
);

project.update_file(
"leaf.R".to_string(),
Arc::new(parse("leaf.R", "renamed <- function() \"s\"\n")),
);
let incremental = project.check_incremental();

let mut cold = Project::new();
cold.add_file(
"leaf.R".to_string(),
parse("leaf.R", "renamed <- function() \"s\"\n"),
);
cold.add_file(
"middle.R".to_string(),
parse("middle.R", "mid <- function() helper()\n"),
);
cold.add_file(
"top.R".to_string(),
parse("top.R", "result <- mid() + 1L\n"),
);
let cold = cold.check();

assert_eq!(incremental, cold);
}
Loading