diff --git a/hy/compiler.py b/hy/compiler.py index bad6434..4852d7e 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -341,6 +341,7 @@ class HyASTCompiler(object): col_offset=e.start_column) @builds("+") + @builds("%") @builds("-") @builds("/") @builds("*") @@ -352,7 +353,8 @@ class HyASTCompiler(object): ops = {"+": ast.Add, "/": ast.Div, "*": ast.Mult, - "-": ast.Sub} + "-": ast.Sub, + "%": ast.Mod} inv = expression.pop(0) op = ops[inv] diff --git a/tests/native_tests/math.hy b/tests/native_tests/math.hy index a593ea3..6172972 100644 --- a/tests/native_tests/math.hy +++ b/tests/native_tests/math.hy @@ -28,3 +28,7 @@ (def test_div (fn [] "NATIVE: Test division" (assert (= 25 (/ 100 2 2))))) + +(defn test-modulo [] + "NATIVE: test mod" + (assert (= (% 10 2) 0)))