-
Notifications
You must be signed in to change notification settings - Fork 0
Using Typeon (Sample)
orweis edited this page Aug 2, 2012
·
2 revisions
Code sample with Typeon:
import typeon ## Step 1
##Step 2- Write your code
#Define a function with typed arguments (int r, float fraction)
def doMath( (int,r), (float,fraction) ):
if item is True:
r = 0
r = r + 1
r = r + ""
return r / int(fraction)
def mainTest():
doMath("gg", "88")
doMath(1, "h")
## Step 3- last step - Invoke Typeon.
typeon.compile()
The above code contains many errors (type based and not)
Here’s what Importing/Running the module will give you via Typeon:
TypeonException: Module "C:\Proj\typeon\Sample.py"
1. Name 'item' is not defined -(line:10 col:7 )
2. Type mismatch between r, type<str> using opertaor 'Add'. - (line:13 col:8 )
3. Bad type passed to function 'doMath' for argument '0'.
'str' instead of 'int' - (line:18 col:4 )
4. Bad type passed to function 'doMath' for argument '1'.
'str' instead of 'float' - (line:18 col:4 )
5. Bad type passed to function 'doMath' for argument '1'.
'str' instead of 'float' - (line:19 col:4 )