Skip to content

Commit cd03a8a

Browse files
committed
fix #6139
1 parent a49856e commit cd03a8a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/ast.c

+2
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ jl_value_t *jl_parse_next(void)
477477
if (c == FL_EOF)
478478
return NULL;
479479
if (iscons(c)) {
480+
if (cdr_(c) == FL_EOF)
481+
return NULL;
480482
value_t a = car_(c);
481483
if (isfixnum(a)) {
482484
jl_lineno = numval(a);

src/jlfrontend.scm

+15-12
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,22 @@
181181
(set! *ts-stack* (cdr *ts-stack*)))
182182

183183
(define (jl-parser-next)
184-
(skip-ws-and-comments (ts:port current-token-stream))
185-
(let ((lineno (input-port-line (ts:port current-token-stream))))
186-
(let ((e (parser-wrap (lambda ()
187-
(julia-parse current-token-stream)))))
188-
(if (eof-object? e)
189-
e
190-
(cons lineno
191-
(parser-wrap
192-
(lambda ()
193-
(if (and (pair? e) (or (eq? (car e) 'error)
194-
(eq? (car e) 'continue)))
184+
(let* ((err (parser-wrap
185+
(lambda ()
186+
(skip-ws-and-comments (ts:port current-token-stream)))))
187+
(lineno (input-port-line (ts:port current-token-stream))))
188+
(cons lineno
189+
(if (pair? err)
190+
err
191+
(parser-wrap
192+
(lambda ()
193+
(let ((e (julia-parse current-token-stream)))
194+
(if (eof-object? e)
195195
e
196-
(expand-toplevel-expr e)))))))))
196+
(if (and (pair? e) (or (eq? (car e) 'error)
197+
(eq? (car e) 'continue)))
198+
e
199+
(expand-toplevel-expr e))))))))))
197200

198201
; expand a piece of raw surface syntax to an executable thunk
199202
(define (jl-expand-to-thunk expr)

0 commit comments

Comments
 (0)