From 9b30e7b7f9570cae5899b47a5d4fc348e750bb6e Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 8 Feb 2018 12:09:56 -0500 Subject: [PATCH] make syntax that expands to calls always call functions in Base fixes #25947 --- src/julia-syntax.scm | 10 +++++----- test/syntax.jl | 12 ++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 60f6fa80f5b3e..28df69e3949b1 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -1515,7 +1515,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)) @@ -2054,7 +2054,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) @@ -2292,7 +2292,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) @@ -2309,10 +2309,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)))) diff --git a/test/syntax.jl b/test/syntax.jl index 28afb15ba3b1e..b659305c90b99 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1281,6 +1281,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()")