Here is a drastically simplified and self-contained fragment of code dealing with permutation groups. The point of my post is that without the line `let s=s, i=i, e=i^s`

the compiler cannot infer the type of either s, i or e, as @code_warntype shows. I spent literally days on this kind of problem, almost giving up on Julia along the way, before I stumbled on a similar problem/solution in a post on this (very useful) forum, and discovered that this kind of bug is all over my code and can invariably be fixed in a similar way. So my questions are:

- What is going on here exactly?
- Is this a temporary bug which is going to be fixed? (it is on 0.6.3 and on 0.7alpha)
- If not, why is this not mentioned in the section â€śPerformance tipsâ€ť?

```
# a permutation is defined by the list d holding the images of 1:length(d)
struct Perm
d::Vector{Int}
end
degree(a::Perm)= length(a.d)
# i^p : apply permutation p to integer i
import Base.^
^(n::Int, a::Perm)=if n>degree(a) n else a.d[n] end
import Base.*
function *(b::Perm, a::Perm)
if degree(b)<=degree(a)
d=copy(a.d)
for i in 1:degree(b) d[i]=a.d[b.d[i]] end
else
d=[i^a for i in b.d]
end
Perm(d)
end
struct PermGroup # Permutation group with generators gens
gens::Vector{Perm}
end
G=PermGroup([Perm([2,1,3]),Perm([1,3,2])])
# for each q in the orbit of point p under g, record
# in d[p] an element of G sending p to q
function orbit_and_representative(G::PermGroup,p)
new=[p]
d=Dict(p=>Perm(collect(1:degree(G.gens[1]))))
while !isempty(new)
old=copy(new)
resize!(new,0)
for s in G.gens, i in old
let s=s, i=i, e=i^s
get!(d,e) do
push!(new,e)
s*d[i]
end
end
end
end
d
end
@code_warntype orbit_and_representative(G,1)
```