diff --git a/hy/compiler.py b/hy/compiler.py index 15b5832..73b5750 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -204,6 +204,18 @@ class HyASTCompiler(object): kw_defaults=[]), body=self.compile(body)) + @builds("pass") + def compile_pass_expression(self, expr): + return ast.Pass(lineno=expr.start_line, col_offset=expr.start_column) + + @builds("yield") + def compile_yield_expression(self, expr): + expr.pop(0) + return ast.Yield( + value=self.compile(expr.pop(0)), + lineno=expr.start_line, + col_offset=expr.start_column) + @builds("import") def compile_import_expression(self, expr): expr.pop(0) # index diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index f052bf6..04669fa 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -151,3 +151,17 @@ (def vals {"one" "two"}) (assoc vals "two" "three") (assert (= (get vals "two") "three"))) + + +(defn test-pass [] + "NATIVE: Test pass worksish" + (if true (pass) (pass)) + (assert (= 1 1))) + + +(defn test-yield [] + "NATIVE: test yielding" + (defn gen [] (for [x [1 2 3 4]] (yield x))) + (def ret 0) + (for [y (gen)] (def ret (+ ret y))) + (assert (= ret 10)))