Skip to content

Commit bca196c

Browse files
robertoaloimeta-codesync[bot]
authored andcommitted
Do not report an undefined function warning if the function name is a variable
Summary: Counterpart of the previous fix. Do not report potentially false positives in case a function is a variable. Reviewed By: alanz Differential Revision: D84832054 fbshipit-source-id: 4a0b2fde715da4bfcab83f802d95da1a31a797ff
1 parent 7cf2eaf commit bca196c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

crates/ide/src/diagnostics/undefined_function.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl FunctionCallLinter for UndefinedFunctionLinter {
7676

7777
// If the module is a variable, we can't determine at compile time
7878
// whether the function is defined or not, so don't report it
79-
if module.as_var().is_some() {
79+
if module.as_var().is_some() || name.as_var().is_some() {
8080
return None;
8181
}
8282

@@ -401,4 +401,16 @@ exists() -> ok.
401401
"#,
402402
)
403403
}
404+
405+
#[test]
406+
fn test_function_name_variable() {
407+
check_diagnostics(
408+
r#"
409+
//- /src/main.erl
410+
-module(main).
411+
main(Callback) ->
412+
main:Callback().
413+
"#,
414+
)
415+
}
404416
}

0 commit comments

Comments
 (0)