Added global. Not sure if this is a good idea ...
(global foo) => global foo
This commit is contained in:
parent
3f362bc318
commit
18cb7203d3
@ -468,6 +468,15 @@ class HyASTCompiler(object):
|
||||
lineno=e.start_line,
|
||||
col_offset=e.start_column)
|
||||
|
||||
@builds("global")
|
||||
@checkargs(1)
|
||||
def compile_global_expression(self,expr):
|
||||
expr.pop(0) # global
|
||||
e = expr.pop(0)
|
||||
return ast.Global(names=[ast_str(e)],
|
||||
lineno=e.start_line,
|
||||
col_offset=e.start_column)
|
||||
|
||||
@builds("lambda")
|
||||
@checkargs(min=2)
|
||||
def compile_lambda_expression(self, expr):
|
||||
|
@ -185,6 +185,14 @@ def test_ast_bad_assert():
|
||||
cant_compile("(assert)")
|
||||
cant_compile("(assert 1 2)")
|
||||
|
||||
def test_ast_good_global():
|
||||
"Make sure AST can compile valid global"
|
||||
hy_compile(tokenize("(global a)"))
|
||||
|
||||
def test_ast_bad_global():
|
||||
"Make sure AST can't compile invalid global"
|
||||
cant_compile("(global)")
|
||||
cant_compile("(global foo bar)")
|
||||
|
||||
def test_ast_good_lambda():
|
||||
"Make sure AST can compile valid lambda"
|
||||
|
Loading…
Reference in New Issue
Block a user