Skip to content

Latest commit

 

History

History
34 lines (33 loc) · 1.02 KB

README.org

File metadata and controls

34 lines (33 loc) · 1.02 KB

Try using Convert python bytecode to Simple AST and using Stack Machine to simple type check

usage

from TVar import *
from check import T
@T
def sum( ilst : [Int] ) -> Int :
    if ilst == [ ]:
        return 0
    else:
        return ilst[0] + sum(ilst[1:])
"""
this example is right 
but next example is not right
"""
  • bad usage:
    from TVar import *
    from check import T
    @T
    def sum( ilst : [Int] ) -> Int :
        if ilst == [ ]:
            return None
        else:
            return ilst[0] + sum(ilst[1:])
        
    • there will raise error
# when ilst is empty list then sum function return None , None in TVar is Unit ,
# but sum function __annotations__ return type is Int , so , will raise a Error of typecheck
# machine.CheckError: for return type(s): Int and Unit