hy/tests
Zack M. Davis 2ad2d5a418 fix keyword lambda values by retaining statements in Result
As reported in issue #748, there was a bug in which passing a lambda
as the value of a :keyword argument would fail—

$ hy --spy
hy 0.10.1 using CPython(default) 3.4.0 on Linux
=> (sorted (range 10) :key (fn [x] (- x)))
from hy.core.language import range
sorted(range(10), key=_hy_anon_fn_1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name '_hy_anon_fn_1' is not defined

The function call would appear in the generated AST without being
preceded by the appropriate function definition corresponding to the
anonymous function argument value in the Hy source, causing either a
NameError (as in the example above), or erroneous reuse of whatever
function was already pointed to by the `_hy_anon_fn_` name referenced
in the list of keywords passed to `ast.Call`.

This commit aims to fix the problem by handling it in same way that
the expression/statement gap is bridged many other places in the
compiler, by adding the compiled value of the keyword argument to the
Result object being built during `_compile_collect`, with the
understanding that any Python statements implied by the argument value
will be appropriately preserved therein.
2015-04-26 15:57:08 -07:00
..
compilers Assert now may take an optional label, like in Python 2015-02-22 17:34:19 +01:00
importer hy/compiler.py: import only handles HySymbol and HyList, bail on others 2014-02-11 17:29:50 +01:00
lex Add support for multi-line strings in interpreter 2014-12-28 23:38:38 -06:00
macros Add tests for _wrap_value 2014-09-21 12:08:14 -04:00
models Merge master onto pr/471 2014-01-30 21:50:23 +05:30
native_tests fix keyword lambda values by retaining statements in Result 2015-04-26 15:57:08 -07:00
resources Fixes a long-standing bug in import under Python 3.3 and later. 2014-12-07 11:02:48 -07:00
test_files Run file using hy -i 2015-02-28 18:11:42 +10:00
__init__.py Merge branch 'master' into pr/579 2014-11-15 08:02:41 -05:00
test_bin.py Run file using hy -i 2015-02-28 18:11:42 +10:00