Skip to content

Commit 1d1a488

Browse files
authored
fix #25020, syntax error for using X() (#25836)
1 parent 4fe91bd commit 1d1a488

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: src/julia-parser.scm

+3-2
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@
10581058
(and (not (number? t)) ;; disallow "x.3" and "sqrt(2)2"
10591059
(not (eqv? t #\@)) ;; disallow "x@time"
10601060
;; issue #16427, disallow juxtaposition with block forms
1061-
(not (and (pair? expr) (block-form? (car expr)))))
1061+
(not (and (pair? expr) (or (block-form? (car expr))
1062+
(syntactic-unary-op? (car expr))
1063+
(initial-reserved-word? (car expr))))))
10621064
;; to allow x'y as a special case
10631065
#;(and (pair? expr) (memq (car expr) '(|'| |.'|))
10641066
(not (memv t '(#\( #\[ #\{))))
@@ -1071,7 +1073,6 @@
10711073
;; issue #20575
10721074
(error "cannot juxtapose string literal"))
10731075
(not (initial-reserved-word? t))
1074-
(not (and (pair? expr) (syntactic-unary-op? (car expr))))
10751076
;; TODO: this would disallow juxtaposition with 0, which is ambiguous
10761077
;; with e.g. hex literals `0x...`. however this is used for `0im`, which
10771078
;; we might not want to break.

Diff for: test/syntax.jl

+3
Original file line numberDiff line numberDiff line change
@@ -1265,3 +1265,6 @@ function bar16239()
12651265
f()
12661266
end
12671267
@test bar16239() == 0
1268+
1269+
# issue #25020
1270+
@test_throws ParseError Meta.parse("using Colors()")

0 commit comments

Comments
 (0)