diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 1244ee986c077..f12638c644437 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1019,6 +1019,9 @@ ((comprehension) (loop (list* 'typed_comprehension ex (cdr al)))) ((dict_comprehension) + (syntax-deprecation + s (string #\( (deparse ex) #\) "[a=>b for (a,b) in c]") + (string (deprecated-dict-replacement ex) "(a=>b for (a,b) in c)")) (loop (list* 'typed_dict_comprehension ex (cdr al)))) (else (error "unknown parse-cat result (internal error)")))))) ((|.|) @@ -1995,7 +1998,7 @@ (syntax-deprecation s "{a for a in b}" "Any[a for a in b]") `(typed_comprehension (top Any) ,@(cdr vex))) ((dict_comprehension) - (syntax-deprecation s "{a=>b for (a,b) in c}" "Dict{Any,Any}([a=>b for (a,b) in c])") + (syntax-deprecation s "{a=>b for (a,b) in c}" "Dict{Any,Any}(a=>b for (a,b) in c)") `(typed_dict_comprehension (=> (top Any) (top Any)) ,@(cdr vex))) ((dict) (syntax-deprecation s "{a=>b, ...}" "Dict{Any,Any}(a=>b, ...)") diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 3bc0e35897dbc..4d0721876c8d3 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2016,6 +2016,7 @@ 'dict_comprehension (lambda (e) + (syntax-deprecation #f "[a=>b for (a,b) in c]" "Dict(a=>b for (a,b) in c)") (expand-forms (lower-dict-comprehension (cadr e) (cddr e)))) 'typed_dict_comprehension diff --git a/test/bitarray.jl b/test/bitarray.jl index f0d705826016b..286965ecc1570 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -515,7 +515,7 @@ for m1 = 1 : v1 + 1 @test b == i b2 = copy(b1) i2 = copy(i1) - i3 = [j => rand(0:1) for j = 1:v2] + i3 = Dict(j => rand(0:1) for j = 1:v2) b = splice!(b2, m1:m2, values(i3)) i = splice!(i2, m1:m2, values(i3)) @test isequal(Array(b2), i2) @@ -545,7 +545,7 @@ for m1 = 1 : v1 @test b == i b2 = copy(b1) i2 = copy(i1) - i3 = [j => rand(0:1) for j = 1:v2] + i3 = Dict(j => rand(0:1) for j = 1:v2) b = splice!(b2, m1:m2, values(i3)) i = splice!(i2, m1:m2, values(i3)) @test isequal(Array(b2), i2) diff --git a/test/dates/io.jl b/test/dates/io.jl index fd0e6630dbfa6..712b22b731da0 100644 --- a/test/dates/io.jl +++ b/test/dates/io.jl @@ -211,7 +211,7 @@ f2 = "dd/mm/yy" const french = Dict("janv"=>1,"févr"=>2,"mars"=>3,"avril"=>4,"mai"=>5,"juin"=>6,"juil"=>7,"août"=>8,"sept"=>9,"oct"=>10,"nov"=>11,"déc"=>12) Dates.MONTHTOVALUEABBR["french"] = french -Dates.VALUETOMONTHABBR["french"] = [v=>k for (k,v) in french] +Dates.VALUETOMONTHABBR["french"] = Dict(v=>k for (k,v) in french) f = "dd uuuuu yyyy" @test Dates.Date("28 mai 2014",f;locale="french") == Dates.Date(2014,5,28) @@ -240,7 +240,7 @@ f = "duy" const globex = Dict("f"=>Dates.Jan,"g"=>Dates.Feb,"h"=>Dates.Mar,"j"=>Dates.Apr,"k"=>Dates.May,"m"=>Dates.Jun, "n"=>Dates.Jul,"q"=>Dates.Aug,"u"=>Dates.Sep,"v"=>Dates.Oct,"x"=>Dates.Nov,"z"=>Dates.Dec) Dates.MONTHTOVALUEABBR["globex"] = globex -Dates.VALUETOMONTHABBR["globex"] = [v=>uppercase(k) for (k,v) in globex] +Dates.VALUETOMONTHABBR["globex"] = Dict(v=>uppercase(k) for (k,v) in globex) @test Dates.Date("1F4",f;locale="globex") + Dates.Year(2010) == Dates.Date(2014,1,1) @test Dates.format(Dates.Date(2014,1,1),f;locale="globex") == "1F4" diff --git a/test/dict.jl b/test/dict.jl index a9351357df14d..e1bb085c4acd2 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -261,9 +261,9 @@ end # show for d in (Dict("\n" => "\n", "1" => "\n", "\n" => "2"), - [string(i) => i for i = 1:30], - [reshape(1:i^2,i,i) => reshape(1:i^2,i,i) for i = 1:24], - [String(Char['α':'α'+i;]) => String(Char['α':'α'+i;]) for i = (1:10)*10], + Dict(string(i) => i for i = 1:30), + Dict(reshape(1:i^2,i,i) => reshape(1:i^2,i,i) for i = 1:24), + Dict(String(Char['α':'α'+i;]) => String(Char['α':'α'+i;]) for i = (1:10)*10), Dict("key" => zeros(0, 0))) for cols in (12, 40, 80), rows in (2, 10, 24) # Ensure output is limited as requested @@ -319,12 +319,12 @@ let sbuff = IOBuffer(), end # issue #2540 -let d = Dict{Any,Any}([x => 1 for x in ['a', 'b', 'c']]) +let d = Dict{Any,Any}(Dict(x => 1 for x in ['a', 'b', 'c'])) @test d == Dict('a'=>1, 'b'=>1, 'c'=> 1) end # issue #2629 -let d = Dict{AbstractString,AbstractString}([ a => "foo" for a in ["a","b","c"]]) +let d = Dict{AbstractString,AbstractString}(Dict( a => "foo" for a in ["a","b","c"])) @test d == Dict("a"=>"foo","b"=>"foo","c"=>"foo") end diff --git a/test/hashing.jl b/test/hashing.jl index 98bf8a4a0788a..9ee196c119e1e 100644 --- a/test/hashing.jl +++ b/test/hashing.jl @@ -67,7 +67,7 @@ vals = Any[ (1,2,3,4), (1.0,2.0,3.0,4.0), (1,3,2,4), ("a","b"), (SubString("a",1,1), SubString("b",1,1)), # issue #6900 - [x => x for x in 1:10], + Dict(x => x for x in 1:10), Dict(7=>7,9=>9,4=>4,10=>10,2=>2,3=>3,8=>8,5=>5,6=>6,1=>1), [], [1], [2], [1, 1], [1, 2], [1, 3], [2, 2], [1, 2, 2], [1, 3, 3], zeros(2, 2), spzeros(2, 2), eye(2, 2), speye(2, 2),