Fix HyMacroExpansionError underline alignment
This commit is contained in:
parent
ca1bd0ffd3
commit
e478008cce
@ -103,7 +103,9 @@ class HyREPL(code.InteractiveConsole):
|
|||||||
tokens = tokenize(source)
|
tokens = tokenize(source)
|
||||||
except PrematureEndOfInput:
|
except PrematureEndOfInput:
|
||||||
return True
|
return True
|
||||||
tokens = tokenize("(do " + source + "\n)")
|
do = HyExpression([HySymbol('do')] + tokens)
|
||||||
|
do.start_line = do.end_line = do.start_column = do.end_column = 1
|
||||||
|
do.replace(do)
|
||||||
except LexException as e:
|
except LexException as e:
|
||||||
if e.source is None:
|
if e.source is None:
|
||||||
e.source = source
|
e.source = source
|
||||||
@ -119,7 +121,7 @@ class HyREPL(code.InteractiveConsole):
|
|||||||
new_ast = ast.Module(main_ast.body +
|
new_ast = ast.Module(main_ast.body +
|
||||||
[ast.Expr(expr_ast.body)])
|
[ast.Expr(expr_ast.body)])
|
||||||
print(astor.to_source(new_ast))
|
print(astor.to_source(new_ast))
|
||||||
value = hy_eval(tokens[0], self.locals, "__console__",
|
value = hy_eval(do, self.locals, "__console__",
|
||||||
ast_callback)
|
ast_callback)
|
||||||
except HyTypeError as e:
|
except HyTypeError as e:
|
||||||
if e.source is None:
|
if e.source is None:
|
||||||
|
@ -109,6 +109,11 @@ def test_bin_hy_stdin_as_arrow():
|
|||||||
assert re.match(r"=>\s+2L?\s+=>", output)
|
assert re.match(r"=>\s+2L?\s+=>", output)
|
||||||
|
|
||||||
|
|
||||||
|
def test_bin_hy_stdin_error_underline_alignment():
|
||||||
|
_, err = run_cmd("hy", "(defmacro mabcdefghi [x] x)\n(mabcdefghi)")
|
||||||
|
assert "\n (mabcdefghi)\n ^----------^" in err
|
||||||
|
|
||||||
|
|
||||||
def test_bin_hy_stdin_hy_repr():
|
def test_bin_hy_stdin_hy_repr():
|
||||||
output, _ = run_cmd("hy", '(+ [1] [2])')
|
output, _ = run_cmd("hy", '(+ [1] [2])')
|
||||||
assert "[1, 2]" in output.replace('L', '')
|
assert "[1, 2]" in output.replace('L', '')
|
||||||
|
Loading…
Reference in New Issue
Block a user