Skip to content

Commit 28306f6

Browse files
authored
Merge pull request #21301 from JuliaLang/jb/underscore_lineno
try to add location info to `_` deprecation warning
2 parents d9ba3d9 + aff0eb8 commit 28306f6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/julia-syntax.scm

+10-5
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,11 @@
730730
`(,(car sig) ,item ,@(cdr sig))
731731
`(,item ,@sig)))
732732

733+
(define (linenode-string lno)
734+
(cond ((length= lno 2) (string " around line " (cadr lno)))
735+
((length= lno 3) (string " around " (caddr lno) ":" (cadr lno)))
736+
(else "")))
737+
733738
(define (ctor-signature name params bounds method-params sig)
734739
(if (null? params)
735740
(if (null? method-params)
@@ -774,10 +779,7 @@
774779
body))
775780
(lno (if (null? lnos) '() (car lnos))))
776781
(syntax-deprecation #f
777-
(string "inner constructor " name "(...)"
778-
(cond ((length= lno 2) (string " around line " (cadr lno)))
779-
((length= lno 3) (string " around " (caddr lno) ":" (cadr lno)))
780-
(else "")))
782+
(string "inner constructor " name "(...)" (linenode-string lno))
781783
(deparse `(where (call (curly ,name ,@params) ...) ,@params)))))
782784
`(,keyword ,sig ,(ctor-body body params)))))))
783785

@@ -3228,6 +3230,7 @@ f(x) = yt(x)
32283230
(let ((code '())
32293231
(filename 'none)
32303232
(first-line #t)
3233+
(current-loc #f)
32313234
(rett #f)
32323235
(arg-map #f) ;; map arguments to new names if they are assigned
32333236
(label-counter 0) ;; counter for generating label addresses
@@ -3320,7 +3323,8 @@ f(x) = yt(x)
33203323
(and (pair? e) (or (eq? (car e) 'outerref)
33213324
(eq? (car e) 'globalref))
33223325
(eq? (cadr e) '_))))
3323-
(syntax-deprecation #f "_ as an rvalue" ""))
3326+
(syntax-deprecation #f (string "_ as an rvalue" (linenode-string current-loc))
3327+
""))
33243328
(cond (tail (emit-return e1))
33253329
(value e1)
33263330
((or (eq? e1 'true) (eq? e1 'false)) #f)
@@ -3561,6 +3565,7 @@ f(x) = yt(x)
35613565
((import importall using export line meta inbounds boundscheck simdloop)
35623566
(let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return))))
35633567
(cond ((eq? (car e) 'line)
3568+
(set! current-loc e)
35643569
(if first-line
35653570
(begin (set! first-line #f)
35663571
(emit e))

0 commit comments

Comments
 (0)