Fix #151 (again!): yield inside with wasn't propagated to Result

This commit is contained in:
Ryan Gonzalez 2017-03-08 10:37:45 -06:00
parent 484daafa53
commit 7c82c01a6a
3 changed files with 27 additions and 16 deletions

32
NEWS
View File

@ -15,6 +15,8 @@ Changes from 0.12.1
* Shadowed comparison operators now use `and` instead of `&`
for chained comparisons
* partition no longer prematurely exhausts input iterators
* A `yield` inside of a `with` statement will properly suppress implicit
returns.
Changes from 0.12.0
@ -161,7 +163,7 @@ Changes from 0.10.0
* doto macro added
* keyword? to find out keywords
* setv no longer allows "." in names
[Internals ]
* Builtins reimplemented in terms of python stdlib
* gensyms (defmacro/g!) handles non-string types better
@ -188,12 +190,12 @@ Changes from 0.9.12
- Hy Society
[ Breaking Changes ]
We're calling this release 0.10 because we broke
API. Sorry about that. We've removed kwapply in
API. Sorry about that. We've removed kwapply in
favor of using `apply`. Please be sure to upgrade
all code to work with `apply`.
(apply function-call args kwargs) ; is the signature
[Thanks]
@ -202,17 +204,17 @@ Changes from 0.9.12
As always, massive hugs to olasd for the constant reviews and for
implementing HyCons cells. Thanks to @kenanb for redesigning the
new Hy logo.
Many thanks to algernon for working on adderall, which helped
push Hy further this cycle. Adderall is an implementation of miniKanren
in Hy. If you're interested in using Adderall, check out hydiomatic,
which prettifies Hy source using Adderall rules.
This release saw an increase of about 11 contributors for a point
release, you guys rock!
-Hy Society
[ Language Changes ]
* `for' revamped again (Last time, we hope!), this time using a saner
@ -230,7 +232,7 @@ Changes from 0.9.12
* `disassemble' added to core, which dumps the AST or equivalent python code
* `coll?' added to core to check for a collection
* `identity' function added to core
[ Misc. Fixes ]
* Lots of doc fixes. Reorganization as well as better docs on Hy internals
* Universal Wheel Support
@ -238,11 +240,11 @@ Changes from 0.9.12
from clojure to hy
* Hy REPL supports invoking with --spy & -i options [reword]
* `first' and `rest' are functions and not macros anymore
* "clean" target added to Makefile
* "clean" target added to Makefile
* hy2py supports a bunch of commandline options to show AST, source etc.
* Sub-object mangling: every identifier is split along the dots & mangled
separately
[ Bug Fixes ]
* Empty MacroExpansions work as expected
* Python 3.4 port. Sorry this wasn't in a 3.4 release time, we forgot to do
@ -266,18 +268,18 @@ Changes from Hy 0.9.11
0.9.12 comes with some massive changes,
We finally took the time to implement gensym, as well as a few
other bits that help macro writing. Check the changelog for
what exactly was added.
what exactly was added.
The biggest feature, Reader Macros, landed later
in the cycle, but were big enough to warrant a release on its
own. A huge thanks goes to Foxboron for implementing them
and a massive hug goes out to olasd for providing ongoing
reviews during the development.
Welcome to the new Hy contributors, Henrique Carvalho Alves,
Kevin Zita and Kenan Bölükbaşı. Thanks for your work so far,
folks!
Hope y'all enjoy the finest that 2013 has to offer,
- Hy Society
@ -388,7 +390,7 @@ Changes from Hy 0.9.10
Changes from Hy 0.9.9
[ Stupid Fixes ]
* I forgot to include hy.core.language in the sdist. (PT)
Changes from Hy 0.9.8

View File

@ -1485,6 +1485,7 @@ class HyASTCompiler(object):
optional_vars=thing)]
ret = ctx + the_with
ret.contains_yield = ret.contains_yield or body.contains_yield
# And make our expression context our temp variable
expr_name = ast.Name(id=ast_str(var), arg=ast_str(var),
ctx=ast.Load(),

View File

@ -724,6 +724,14 @@
(with [(open "README.md" "r")] (do)))
(defn test-context-yield []
"NATIVE: test yields inside of with statements don't try to return before Python 3.3"
(defn f []
(with [(open "README.md")] (yield 123)))
(assert (= (next (f)) 123)))
(defn test-with-return []
"NATIVE: test that with returns stuff"
(defn read-file [filename]
@ -893,7 +901,7 @@
(defn test-and []
"NATIVE: test the and function"
(setv and123 (and 1 2 3)
and-false (and 1 False 3)
and-true (and)