Created
March 2, 2019 06:37
-
-
Save milesrout/20ced746309e494a0a37704e168b2ccb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUG = True | |
macro ASSERT(e): | |
return \(if DEBUG: | |
if not $e: | |
raise AssertionError($(stringify(e)))) | |
def assert_equal(x, z): | |
# x and z are compared so they must have the same type | |
ASSERT(x == z) | |
def foo(x): | |
# x is used in an addition to an integer, so it gets unified with integer | |
y = x + 1 | |
# assert_equal takes two parameters of the same type, so these must have the same type | |
assert_equal(x, "test") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR CHECKING TYPES | |
18:17: Cannot unify int and string | |
assert_equal(x, "test") | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment