@@ -10764,6 +10764,9 @@ do
10764
10764
if node.if_block_n > 1 then
10765
10765
self:infer_negation_of_if_blocks(node, node.if_parent, node.if_block_n - 1)
10766
10766
end
10767
+ if node.exp then
10768
+ node.exp.expected = a_type(node, "boolean", {})
10769
+ end
10767
10770
end ,
10768
10771
before_statements = function (self : TypeChecker , node : Node )
10769
10772
if node .exp then
@@ -10784,6 +10787,7 @@ do
10784
10787
before = function(self: TypeChecker, node: Node)
10785
10788
-- widen all narrowed variables because we don't calculate a fixpoint yet
10786
10789
self:widen_all_unions(node)
10790
+ node.exp.expected = a_type(node, "boolean", {})
10787
10791
end ,
10788
10792
before_statements = function (self : TypeChecker , node : Node )
10789
10793
self:begin_scope(node )
@@ -10847,6 +10851,7 @@ do
10847
10851
before = function(self: TypeChecker, node: Node)
10848
10852
-- widen all narrowed variables because we don't calculate a fixpoint yet
10849
10853
self:widen_all_unions(node)
10854
+ node.exp.expected = a_type(node, "boolean", {})
10850
10855
end ,
10851
10856
-- only end scope after checking `until `, `statements ` in repeat body has is_repeat == true
10852
10857
after = end_scope_and_none_type ,
@@ -11707,6 +11712,10 @@ do
11707
11712
end
11708
11713
t = drop_constant_value (t )
11709
11714
end
11715
+
11716
+ if expected and expected is BooleanType then
11717
+ t = a_type (node , "boolean ", {})
11718
+ end
11710
11719
end
11711
11720
11712
11721
if t then
0 commit comments