Skip to content

Commit 62a6f5d

Browse files
kbansalfacebook-github-bot
authored andcommitted
Uninitialized local: Add examples of false positives
Reviewed By: dkgi Differential Revision: D28967091 fbshipit-source-id: 8f71f34b6a580de4d91417d64bd15c14614c5b3f
1 parent 4ac80be commit 62a6f5d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

source/analysis/test/uninitializedLocalCheckTest.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ let test_simple context =
9292
|}
9393
[];
9494

95+
(* shouild be: no errors *)
96+
assert_uninitialized_errors
97+
{|
98+
def f():
99+
def g():
100+
pass
101+
g()
102+
|}
103+
["Unbound name [10]: Name `g` is used but not defined in the current scope."];
104+
105+
(* should be: no errors *)
106+
assert_uninitialized_errors
107+
{|
108+
def f():
109+
x, y = 0, 0
110+
return x, y
111+
|}
112+
[
113+
"Unbound name [10]: Name `x` is used but not defined in the current scope.";
114+
"Unbound name [10]: Name `y` is used but not defined in the current scope.";
115+
];
116+
95117
(* Extracted from a real-world example. should be: In foo(harness_config), harness_config might
96118
not be defined. *)
97119
assert_uninitialized_errors

0 commit comments

Comments
 (0)