File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,12 @@ def run(self) -> dict[Instr, ConstantLattice]:
798798 new_type = CInt (l + r )
799799 case (CInt (_), CInt (_)):
800800 new_type = CInt ()
801+ elif isinstance (instr , IntSub ):
802+ match (self .type_of (instr .operands [0 ]), self .type_of (instr .operands [1 ])):
803+ case (CInt (int (l )), CInt (int (r ))):
804+ new_type = CInt (l - r )
805+ case (CInt (_), CInt (_)):
806+ new_type = CInt ()
801807 elif isinstance (instr , ListCons ):
802808 if isinstance (self .type_of (instr .operands [1 ]), CList ):
803809 new_type = CList ()
@@ -1898,6 +1904,9 @@ def test_int(self) -> None:
18981904 def test_int_add (self ) -> None :
18991905 self .assertEqual (_run ("1 + 2" ), "3\n " )
19001906
1907+ def test_int_sub (self ) -> None :
1908+ self .assertEqual (_run ("1 - 2" ), "-1\n " )
1909+
19011910 def test_fun_id (self ) -> None :
19021911 self .assertEqual (_run ("a -> a" ), "<closure>\n " )
19031912
You can’t perform that action at this time.
0 commit comments