Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jb/globalvarchecks'
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed May 7, 2016
2 parents 97b4987 + 3f59c0d commit 26cebb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ function exprtype(x::ANY, sv::InferenceState)
end

# known affect-free calls (also effect-free)
const _pure_builtins = Any[tuple, svec, fieldtype, apply_type, is, isa, typeof, typeassert]
const _pure_builtins = Any[tuple, svec, fieldtype, apply_type, is, isa, typeof]

# known effect-free calls (might not be affect-free)
const _pure_builtins_volatile = Any[getfield, arrayref]
Expand Down Expand Up @@ -2198,8 +2198,8 @@ function effect_free(e::ANY, sv, allow_volatile::Bool)
return true
end
if isa(e,GlobalRef)
allow_volatile && return true
return isconst(e.mod, e.name)
return (isdefined(e.mod, e.name) &&
(allow_volatile || isconst(e.mod, e.name)))
end
if isa(e,Expr)
e = e::Expr
Expand Down
7 changes: 7 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3962,3 +3962,10 @@ g16153(x::ANY, y::ANY) = 2
gg16153(x::ANY, y::ANY) = 2
gg16153(x::ANY, y...) = 1
@test gg16153(1, 1) == 2

# don't remove global variable accesses even if we "know" their type
# see #16090
f16090() = typeof(undefined_x16090::Tuple{Type{Int}})
@test_throws UndefVarError f16090()
undefined_x16090 = (Int,)
@test_throws TypeError f16090()

0 comments on commit 26cebb6

Please sign in to comment.