Skip to content

Commit

Permalink
add deprecation for statement position x::T construct to declare a …
Browse files Browse the repository at this point in the history
…local variable

and fix a bug in env.jl where a typeassert was intended

ref #16071
  • Loading branch information
vtjnash committed Jul 21, 2016
1 parent fe31a14 commit a14ba1a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
10 changes: 5 additions & 5 deletions base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ if is_windows()
start(hash::EnvHash) = (pos = ccall(:GetEnvironmentStringsW,stdcall,Ptr{UInt16},()); (pos,pos))
function done(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
if unsafe_load(block[1]) == 0
ccall(:FreeEnvironmentStringsW,stdcall,Int32,(Ptr{UInt16},),block[2])
ccall(:FreeEnvironmentStringsW, stdcall, Int32, (Ptr{UInt16},), block[2])
return true
end
false
return false
end
function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
pos = block[1]
Expand All @@ -102,7 +102,7 @@ function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
if m === nothing
error("malformed environment entry: $env")
end
(Pair{String,String}(m.captures[1], m.captures[2]), (pos+len*2, blk))
return (Pair{String,String}(m.captures[1], m.captures[2]), (pos+len*2, blk))
end

else # !windows
Expand All @@ -114,12 +114,12 @@ function next(::EnvHash, i)
if env === nothing
throw(BoundsError())
end
env::String
env = env::String
m = match(r"^(.*?)=(.*)$"s, env)
if m === nothing
error("malformed environment entry: $env")
end
(Pair{String,String}(m.captures[1], m.captures[2]), i+1)
return (Pair{String,String}(m.captures[1], m.captures[2]), i+1)
end

end # os-test
Expand Down
10 changes: 5 additions & 5 deletions base/float16.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

function convert(::Type{Float32}, val::Float16)
ival::UInt32 = reinterpret(UInt16, val)
sign::UInt32 = (ival & 0x8000) >> 15
exp::UInt32 = (ival & 0x7c00) >> 10
sig::UInt32 = (ival & 0x3ff) >> 0
ret::UInt32
local ival::UInt32 = reinterpret(UInt16, val),
sign::UInt32 = (ival & 0x8000) >> 15,
exp::UInt32 = (ival & 0x7c00) >> 10,
sig::UInt32 = (ival & 0x3ff) >> 0,
ret::UInt32

if exp == 0
if sig == 0
Expand Down
3 changes: 1 addition & 2 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,7 @@ end
### BLAS-2 / sparse A * sparse x -> dense y

function densemv(A::SparseMatrixCSC, x::AbstractSparseVector; trans::Char='N')
xlen::Int
ylen::Int
local xlen::Int, ylen::Int
m, n = size(A)
if trans == 'N' || trans == 'n'
xlen = n; ylen = m
Expand Down
6 changes: 4 additions & 2 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,10 @@
(else
`(block
,.(map (lambda (x)
(if (decl? x)
`(decl ,@(map expand-forms (cdr x)))
(if (and (decl? x) (length= (cdr x) 2) (symbol? (cadr x)))
(let ((str-x (deparse x)))
(syntax-deprecation #f str-x (string "local " str-x))
`(decl ,@(map expand-forms (cdr x))))
(expand-forms x)))
(butlast (cdr e)))
,(expand-forms (last (cdr e)))))))
Expand Down
5 changes: 3 additions & 2 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3134,8 +3134,9 @@ immutable Foo11874
end

function bar11874(x)
y::Foo11874
y=x
local y::Foo11874
y = x
nothing
end

Base.convert(::Type{Foo11874},x::Int) = float(x)
Expand Down

0 comments on commit a14ba1a

Please sign in to comment.