Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate const on local variables, which used to be ignored #23259

Merged
merged 1 commit into from
Aug 15, 2017

Conversation

JeffBezanson
Copy link
Sponsor Member

part of #5148

@tkelman tkelman added the deprecation This change introduces or involves a deprecation label Aug 14, 2017
Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Travis macOS failure suggests that something in

let
     local MatOrNot, my_func, M
     MatOrNot{T} = Union{AbstractMatrix{T}, Vector{Union{}}}
     my_func(A::MatOrNot{T}, B::MatOrNot{T}, C::MatOrNot{T}) where {T<:Real} = 0
     M = [ 2. 1. ; 1. 1. ]
     @test my_func(Union{}[], M, M) == 0
 end

from test/core.jl (around line 849) triggers the depwarn. Perhaps the MatOrNot{T} = Union{...}?

@tkelman
Copy link
Contributor

tkelman commented Aug 15, 2017

add a todo note in deprecated.jl so this gets removed at the right time?

@StefanKarpinski
Copy link
Sponsor Member

Technically, since the behavior of that would change if local const was enforced (in that you would cease to be able to reassign the name), so I guess the only real choice in this PR is to change it.

@JeffBezanson
Copy link
Sponsor Member Author

I think we're fine here. Both f() = ... and t{} = ... now create const bindings only in global scope. Function definitions have always worked this way:

julia> f() = 0
f (generic function with 1 method)

julia> f = 1
ERROR: invalid redefinition of constant f

julia> function g()
         h() = 0
         h = 1
       end
g (generic function with 1 method)

julia> g()
1

@JeffBezanson JeffBezanson merged commit 0df3f7d into master Aug 15, 2017
@JeffBezanson JeffBezanson deleted the jb/localconst branch August 15, 2017 16:49
martinholters added a commit to HSU-ANT/ACME.jl that referenced this pull request Aug 29, 2017
They wre ignored anyway and have been deprecated in
JuliaLang/julia#23259.
marius311 added a commit to marius311/PyCall.jl that referenced this pull request Sep 17, 2018
marius311 added a commit to marius311/PyCall.jl that referenced this pull request Sep 17, 2018
stevengj pushed a commit to JuliaPy/PyCall.jl that referenced this pull request Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants