Skip to content

Commit 8ed946b

Browse files
authored
Merge pull request #19732 from stevengj/dotdot
fix ability to use .. as an infix operator
2 parents ed1183b + bb05e88 commit 8ed946b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/ast.scm

+6-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@
195195
(cadr (caddr e))
196196
e))
197197

198-
(define (dotop? o) (and (symbol? o) (eqv? (string.char (string o) 0) #\.)))
198+
(define (dotop? o) (and (symbol? o) (eqv? (string.char (string o) 0) #\.)
199+
(not (eq? o '|.|))
200+
(not (eqv? (string.char (string o) 1) #\.))))
199201

200202
; convert '.xx to 'xx
201203
(define (undotop op)
@@ -207,7 +209,9 @@
207209
(define (maybe-undotop e)
208210
(if (symbol? e)
209211
(let ((str (string e)))
210-
(if (eqv? (string.char str 0) #\.)
212+
(if (and (eqv? (string.char str 0) #\.)
213+
(not (eq? e '|.|))
214+
(not (eqv? (string.char str 1) #\.)))
211215
(symbol (string.sub str 1 (length str)))
212216
#f))
213217
(if (pair? e)

src/julia-parser.scm

+1-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@
108108
(define dot-opchar? (Set
109109
(delete-duplicates
110110
(map (lambda (op) (string.char (string op) 1))
111-
(filter (lambda (op) (and (dotop? op) (not (eq? op '|.|))))
112-
operators)))))
111+
(cons `|..| (filter dotop? operators))))))
113112
(define operator? (Set operators))
114113

115114
(define initial-reserved-words '(begin while if for try return break continue

test/parse.jl

+4
Original file line numberDiff line numberDiff line change
@@ -863,3 +863,7 @@ end
863863

864864
@test QualifiedStringMacro.SubModule.x"" === 1
865865
@test QualifiedStringMacro.SubModule.y`` === 2
866+
867+
let ..(x,y) = x + y
868+
@test 3 .. 4 === 7
869+
end

0 commit comments

Comments
 (0)