This error appears to occur when defining the function, not while running it, correct? In that case the input isn’t actually needed.
You seem to have an extra end loitering about, probably the one here:
for unts in 1:n_h
p = 1/(1+exp(-(fantasy_visible'*w[:,unts])))
fantasy_hidden[unts] = rand(Bernoulli(p))
end # <- oops
end