title: Lisp void-variable error when evaluating function
body: <p>I'm trying to learn Lisp (elisp, actually), and I tried writing the following function as an exercise Project Euler <a href="https://projecteuler.net/problem=2" rel="nofollow noreferrer">Problem 2</a></p>
  
  <pre><code>(defun sumfib (n fn1 fn2 sum)
    "Calculate Fibonacci numbers up to 4,000,000 and sum all the even ones"
    (if (&lt; 4000000 (+ fn1 fn2))
        sum
      (if (equal n 3)
          (sumfib 1 (+ fn1 fn2) fn1 (+ sum (+fn1 fn2)))
        (sumfib (+ n 1) (+ fn1 fn2) fn1 sum)))
  </code></pre>
  
  <p>When I evaluate it I get the following error:</p>
  
  <pre><code>Debugger entered--Lisp error: (void-variable fn1)
    (+ fn1 fn2)
    (&lt; 4000000 (+ fn1 fn2))
  ...
  </code></pre>
  
  <p>Why wouldn't it recognize fn1? If I try to put (+ fn1 fn2) before the 'if' it doesn't complain about it there, so why the error here?</p>
  
  <p>Also, I realize the function may not actually be correct, but for now I'm not worried about the logic - I'll figure that out later. For now, I'm only interested in understanding this error.</p>