Skip to content
/ vcheck Public

Try using python bytecode to convert to simple ast to check type

License

Notifications You must be signed in to change notification settings

vtheno/vcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Try using python bytecode to convert to simple ast to check type

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages