From 24938178f27b2a2dcd29b9a994ed30cca21e3efc Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 11 Feb 2017 15:33:14 -0500 Subject: [PATCH] add spaces around low-precedence operators in `deparse` add single quotes to Char literals in `deparse` --- src/ast.scm | 3 ++- test/parse.jl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ast.scm b/src/ast.scm index 40321654ee798..7502ebb897ab6 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -25,6 +25,7 @@ ;; successfully printed as a julia value (string.sub s 9 (string.dec s (length s))) s))) + ((char? e) (string "'" e "'")) ((atom? e) (string e)) ((eq? (car e) '|.|) (string (deparse (cadr e)) '|.| @@ -37,7 +38,7 @@ ((memq (car e) '(... |'| |.'|)) (string (deparse (cadr e)) (car e))) ((or (syntactic-op? (car e)) (eq? (car e) '|<:|) (eq? (car e) '|>:|)) - (string (deparse (cadr e)) (car e) (deparse (caddr e)))) + (string (deparse (cadr e)) " " (car e) " " (deparse (caddr e)))) ((memq (car e) '($ &)) (string (car e) (deparse (cadr e)))) ((eq? (car e) '|::|) diff --git a/test/parse.jl b/test/parse.jl index 07b9c93bdab95..fd1f958cad03f 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -808,7 +808,7 @@ for op in ["+", "-", "\$", "|", ".+", ".-", "*", ".*"] end # issue #17701 -@test expand(Main, :(i==3 && i+=1)) == Expr(:error, "invalid assignment location \"==(i,3)&&i\"") +@test expand(Main, :(i==3 && i+=1)) == Expr(:error, "invalid assignment location \"==(i,3) && i\"") # issue #18667 @test expand(Main, :(true = 1)) == Expr(:error, "invalid assignment location \"true\"")