Skip to content

Instantly share code, notes, and snippets.

@milesrout
Created March 2, 2019 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milesrout/20ced746309e494a0a37704e168b2ccb to your computer and use it in GitHub Desktop.
Save milesrout/20ced746309e494a0a37704e168b2ccb to your computer and use it in GitHub Desktop.
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")
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