Skip to content

Commit 129abe3

Browse files
committed
Fixed return with no argument.
Closes GH-3.
1 parent 9c99e7d commit 129abe3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

py2hy/translate.hy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
~@(T x.body))
5252

5353
Return
54-
`(return ~(T x.value))
54+
`(return ~@(when x.value [(T x.value)]))
5555
Delete
5656
`(del ~@(T x.targets))
5757
Assign

tests/test_misc.hy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
(check "x[::-2]" '(cut x None None -2)))
4242

4343

44+
(defn test-return []
45+
; https://github.com/hylang/py2hy/issues/3
46+
(assert (= (2hy "return 1") '(return 1)))
47+
(assert (= (2hy "return None") '(return None)))
48+
(assert (= (2hy "return") '(return))))
49+
50+
4451
(defn test-chained-assignment []
4552
; https://github.com/hylang/py2hy/issues/2
4653

0 commit comments

Comments
 (0)