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

fix #6599 #6605

Merged
merged 3 commits into from
Apr 26, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,12 @@ function effect_free(e::ANY, sv, allow_volatile::Bool)
if is_known_call_p(e, is_pure_builtin, sv)
if !allow_volatile && is_known_call_p(e, (f)->contains_is(_pure_builtins_volatile, f), sv)
# arguments must be immutable to ensure e is affect_free
first = true
for a in ea
if first # first "arg" is the function name
Copy link
Member Author

Choose a reason for hiding this comment

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

this isn't strictly necessary, since the first arg is usually a TopNode. but this should be more correct

first = false
continue
end
if isa(a,Symbol)
return false
end
Expand All @@ -1890,7 +1895,21 @@ function effect_free(e::ANY, sv, allow_volatile::Bool)
end
return true
end
elseif e.head === :new || e.head == :return
elseif e.head == :new
first = !allow_volatile
for a in ea
if first
first = false
isa(a,SymbolNode) || return false
typ = (a::SymbolNode).typ
Copy link
Member

Choose a reason for hiding this comment

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

I believe this should use exprtype and then look for Type{T}, where T is an immutable type.

isa(typ,DataType) || return false
!(typ::DataType).mutable || return false
elseif !effect_free(a,sv,allow_volatile)
return false
end
end
return true
elseif e.head == :return
for a in ea
if !effect_free(a,sv,allow_volatile)
return false
Expand Down