Skip to content

Commit e564008

Browse files
committed
deprecate &x in ccall. fixes #6080
1 parent bad1329 commit e564008

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ Language changes
8888
* Variable bindings local to `while` loop bodies are now freshly allocated on each loop iteration,
8989
matching the behavior of `for` loops.
9090

91+
* Prefix `&` for by-reference arguments to `ccall` has been deprecated in favor of
92+
`Ref` argument types ([#6080]).
93+
9194
Breaking changes
9295
----------------
9396

src/julia-syntax.scm

+7
Original file line numberDiff line numberDiff line change
@@ -3511,6 +3511,13 @@ f(x) = yt(x)
35113511
((call new foreigncall)
35123512
(let* ((args
35133513
(cond ((eq? (car e) 'foreigncall)
3514+
(for-each (lambda (a)
3515+
(if (and (length= a 2) (eq? (car a) '&))
3516+
(deprecation-message
3517+
(string "Syntax \"&argument\"" (linenode-string current-loc)
3518+
" is deprecated. Remove the \"&\" and use a \"Ref\" argument "
3519+
"type instead."))))
3520+
(list-tail e 6))
35143521
;; NOTE: 2nd to 5th arguments of ccall must be left in place
35153522
;; the 1st should be compiled if an atom.
35163523
(append (if (atom? (cadr e))

test/ccall.jl

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ let a
122122
a = 2.84 + 5.2im
123123

124124
@test_throws MethodError ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), a)
125-
@test_throws MethodError ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Complex{Int},), &a)
126125
end
127126

128127

0 commit comments

Comments
 (0)