fix(ast_provenance): resolve duplicate function definitions by usage line span - #71
Conversation
|
@juangaitanv and @Ibrahimrahhal have a look |
| let function = match function_list.len() { | ||
| 0 => return None, | ||
| 1 => &function_list[0], | ||
| _ => { | ||
| if let Some(line) = usage_line { | ||
| let matching: Vec<&FunctionFacts> = function_list | ||
| .iter() | ||
| .filter(|f| line >= f.span.0 && line <= f.span.1) | ||
| .collect(); | ||
| if matching.len() == 1 { | ||
| matching[0] | ||
| } else { | ||
| return Some(AstResolution::Ambiguous); | ||
| } | ||
| } else { | ||
| return Some(AstResolution::Ambiguous); | ||
| } | ||
| } | ||
| }; |
There was a problem hiding this comment.
when the selected definition has no local facts, the text fallback can resolve a different same-named definition; could we return AstResolution::Ambiguous instead?
There was a problem hiding this comment.
@juangaitanv Thanks for the feedback! Updated resolve_variable_reaching in src/scanner/ast_provenance.rs so that when function_list.len() > 1 (duplicate function definitions exist in the file) and the selected definition lacks local facts (no matching assignments or parameters for the variable), it returns Some(AstResolution::Ambiguous). This prevents the text fallback from incorrectly attributing another same-named definition's facts. Added regression test duplicate_function_names_without_local_facts_resolve_as_ambiguous.
Summary
esolve_variable_reaching\ to match the sink's \usage_line\ against each definition's line span when multiple methods in a file share the same bare name (e.g. \get, \post,
un, \handle\ across multiple classes).