Skip to content

Commit

Permalink
make syntax that expands to calls always call functions in Base
Browse files Browse the repository at this point in the history
fixes #25947
  • Loading branch information
JeffBezanson committed Feb 9, 2018
1 parent 125e3e0 commit 3afadd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@
(new-idxs stuff) (process-indices arr idxs)
`(block
,@(append stmts stuff)
(call getindex ,arr ,@new-idxs))))))
(call (top getindex) ,arr ,@new-idxs))))))

(define (expand-update-operator op op= lhs rhs . declT)
(cond ((and (pair? lhs) (eq? (car lhs) 'ref))
Expand Down Expand Up @@ -2062,7 +2062,7 @@
,.(map expand-forms stuff)
,@rini
,(expand-forms
`(call setindex! ,arr ,r ,@new-idxs))
`(call (top setindex!) ,arr ,r ,@new-idxs))
(unnecessary ,r))))))
((|::|)
;; (= (|::| x T) rhs)
Expand Down Expand Up @@ -2300,7 +2300,7 @@
(expand-forms `(call (top vect) ,@(cdr e))))

'hcat
(lambda (e) (expand-forms `(call hcat ,@(cdr e))))
(lambda (e) (expand-forms `(call (top hcat) ,@(cdr e))))

'vcat
(lambda (e)
Expand All @@ -2317,10 +2317,10 @@
(cdr x)
(list x)))
a)))
`(call hvcat
`(call (top hvcat)
(tuple ,.(map length rows))
,.(apply append rows)))
`(call vcat ,@a))))))
`(call (top vcat) ,@a))))))

'typed_hcat
(lambda (e) (expand-forms `(call (top typed_hcat) ,@(cdr e))))
Expand Down
12 changes: 12 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,18 @@ let args = (Int, Any)
@test >:(reverse(args)...)
end

# issue #25947
let getindex = 0, setindex! = 1, colon = 2, vcat = 3, hcat = 4, hvcat = 5
a = [10,9,8]
@test a[2] == 9
@test 1:2 isa AbstractRange
a[1] = 1
@test a[1] == 1
@test length([1; 2]) == 2
@test size([0 0]) == (1, 2)
@test size([1 2; 3 4]) == (2, 2)
end

# issue #25020
@test_throws ParseError Meta.parse("using Colors()")

Expand Down

0 comments on commit 3afadd4

Please sign in to comment.