 
         handleSetLocal: (exp, opencode) ->
                 dest = @findIdentifierInScope exp.arguments[0].name
-                throw new Error "identifier not found: #{exp.arguments[0].name}" if not dest?
+                reportError(ReferenceError, "identifier not found: #{exp.arguments[0].name}", @filename, exp.arguments[0].loc) if not dest?
                 arg = exp.arguments[1]
                 @storeToDest dest, arg
                 ir.createLoad dest, "load_val"


                iife_dest_bb = null
                iife_rv = null
                
                if n.fromIIFE
                        insertBlock = ir.getInsertBlock()
                        insertFunc = insertBlock.parent


                @visitWithScope new_scope, n.body

                @iifeStack.pop()
                
                if fromIIFE

                        ir.createBr iife_dest_bb
                        ir.setInsertPoint iife_dest_bb
                        rv = @createLoad @findIdentifierInScope(n.ejs_iife_rv.name), "%iife_rv_load"
                        return rv
                n

        visitSwitch: (n) ->
                insertBlock = ir.getInsertBlock()
