diff --git a/hy/compiler.py b/hy/compiler.py index 2ced07c..4aa8365 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -961,15 +961,15 @@ class HyASTCompiler(object): @builds("break") def compile_break_expression(self, expr): - ret = ast.Break(lineno=e.start_line, - col_offset=e.start_column) + ret = ast.Break(lineno=expr.start_line, + col_offset=expr.start_column) return ret @builds("continue") def compile_continue_expression(self, expr): - ret = ast.Continue(lineno=e.start_line, - col_offset=e.start_column) + ret = ast.Continue(lineno=expr.start_line, + col_offset=expr.start_column) return ret diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 41de1dc..534ae40 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -685,6 +685,7 @@ 42 43)))) + (defn test-try-except-return [] "NATIVE: test we can return from in a try except" (assert (= ((fn [] (try xxx (except [NameError] (+ 1 1))))) 2)) @@ -729,6 +730,7 @@ "success") (except [NameError] "failure"))))) + (defn test-encoding-nightmares [] "NATIVE: test unicode encoding escaping crazybits" (assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11))) @@ -737,3 +739,19 @@ (defn test-keyword-dict-access [] "NATIVE: test keyword dict access" (assert (= "test" (:foo {:foo "test"})))) + + +(defn test-break-breaking [] + "NATIVE: test checking if break actually breaks" + (defn holy-grail [] (for [x (range 10)] (if (= x 5) (break))) x) + (assert (= (holy-grail) 5))) + + +(defn test-continue-continuation [] + "NATIVE: test checking if continue actually continues" + (setv y []) + (for [x (range 10)] + (if (!= x 5) + (continue)) + (.append y x)) + (assert (= y [5])))