Merge branch 'unary_minus' of github.com:khinsen/hy
This commit is contained in:
commit
3f362bc318
@ -809,7 +809,6 @@ class HyASTCompiler(object):
|
||||
|
||||
@builds("+")
|
||||
@builds("%")
|
||||
@builds("-")
|
||||
@builds("/")
|
||||
@builds("//")
|
||||
@builds("*")
|
||||
@ -848,6 +847,18 @@ class HyASTCompiler(object):
|
||||
left = calc
|
||||
return calc
|
||||
|
||||
@builds("-")
|
||||
@checkargs(min=1)
|
||||
def compile_maths_expression_sub(self, expression):
|
||||
if len(expression) > 2:
|
||||
return self.compile_maths_expression(expression)
|
||||
else:
|
||||
arg = expression[1]
|
||||
return ast.UnaryOp(op=ast.USub(),
|
||||
operand=self.compile(arg),
|
||||
lineno=arg.start_line,
|
||||
col_offset=arg.start_column)
|
||||
|
||||
@builds("+=")
|
||||
@builds("/=")
|
||||
@builds("//=")
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
(setv test_sub (fn []
|
||||
"NATIVE: Test subtraction"
|
||||
(assert (= 4 (- 8 4)))))
|
||||
(assert (= 4 (- 8 4)))
|
||||
(assert (= -8 (- 8)))))
|
||||
|
||||
|
||||
(setv test_add (fn []
|
||||
|
Loading…
Reference in New Issue
Block a user