unstaged changes
This commit is contained in:
parent
9a31fc1f81
commit
fecf17960d
@ -23,4 +23,5 @@ __appname__ = "hy"
|
||||
__version__ = "0.ALPHA.REALLY.1.0~pre0"
|
||||
|
||||
|
||||
import hy.importer
|
||||
import hy.importer # NOQA
|
||||
# we import for side-effects.
|
||||
|
@ -106,34 +106,23 @@ class HyASTCompiler(object):
|
||||
name = "_hy_anon_fn_%d" % (self.anon_fn_count)
|
||||
sig = expression.pop(0)
|
||||
|
||||
ret = ast.FunctionDef(
|
||||
name=name,
|
||||
lineno=expression.start_line,
|
||||
col_offset=expression.start_column,
|
||||
args=ast.arguments(
|
||||
args=[
|
||||
ast.Name(
|
||||
arg=str(x),
|
||||
id=str(x),
|
||||
ctx=ast.Param(),
|
||||
lineno=x.start_line,
|
||||
col_offset=x.start_column
|
||||
) for x in sig
|
||||
],
|
||||
vararg=None,
|
||||
kwarg=None,
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]
|
||||
),
|
||||
body=self._mangle_branch([self.compile(x) for x in expression]),
|
||||
decorator_list=[]
|
||||
)
|
||||
ret = ast.FunctionDef(name=name, vararg=None, kwarg=None,
|
||||
kwonlyargs=[], kw_defaults=[], defaults=[],
|
||||
lineno=expression.start_line,
|
||||
col_offset=expression.start_column,
|
||||
args=ast.arguments(args=[
|
||||
ast.Name(arg=str(x), id=str(x),
|
||||
ctx=ast.Param(),
|
||||
lineno=x.start_line,
|
||||
col_offset=x.start_column)
|
||||
for x in sig]),
|
||||
body=self._mangle_branch([
|
||||
self.compile(x) for x in expression]),
|
||||
decorator_list=[])
|
||||
|
||||
self.returnable = ret_status
|
||||
return ret
|
||||
|
||||
|
||||
@builds(HySymbol)
|
||||
def compile_symbol(self, symbol):
|
||||
return ast.Name(id=str(symbol), ctx=ast.Load(),
|
||||
|
@ -57,3 +57,9 @@ def test_ast_expression_basics():
|
||||
))
|
||||
|
||||
_ast_spotcheck("value.func.id", code, tree)
|
||||
|
||||
|
||||
def test_ast_anon_fns_basics():
|
||||
""" Ensure anon fns work. """
|
||||
code = hy_compile(tokenize("(fn (x) (* x x))")).body[0]
|
||||
assert type(code) == ast.FunctionDef
|
||||
|
Loading…
Reference in New Issue
Block a user