Permalink
Browse files

Fixing the "olasd" bug

  • Loading branch information...
1 parent 1763cb7 commit d421d869af35b1d049c67af74e8a6858c38f993b @paultag committed Apr 4, 2013
Showing with 23 additions and 4 deletions.
  1. +15 −4 hy/compiler.py
  2. +8 −0 tests/native_tests/language.hy
View
@@ -72,10 +72,21 @@ def _mangle_branch(self, tree):
ret.append(ast.Return(value=el,
lineno=el.lineno,
col_offset=el.col_offset))
- ret += [ast.Expr(value=el,
- lineno=el.lineno,
- col_offset=el.col_offset)
- if not isinstance(el, ast.stmt) else el for el in tree] # NOQA
+
+ for el in tree:
+ if type(el) == list:
+ blob = self._mangle_branch(el)
+ blob.reverse()
+ ret += blob
+ continue
+
+ if isinstance(el, ast.stmt):
+ ret.append(el)
+ continue
+
+ ret.append(ast.Expr(value=el,
+ lineno=el.lineno,
+ col_offset=el.col_offset))
ret.reverse()
return ret
@@ -212,6 +212,14 @@
(with-as (open "README.md" "r") fd
(pass)))
+(defn test-for-doodle []
+ "NATIVE: test for-do"
+ (setf (, x y) (, 0 0))
+ (foreach [- [1 2]]
+ (do
+ (setf x (+ x 1))
+ (setf y (+ y 1))))
+ (assert (= y x 2)))
(defn test-comprehensions []
"NATIVE: test list comprehensions"

0 comments on commit d421d86

Please sign in to comment.