     deferredCount = 0
     while (_notEmpty ctx.deferred()) and deferredCount < ctx.deferred().length
       prevSize = ctx.deferred().length
-      [dependencyName, lhs, rhs] = deferred = ctx.deferred().shift()
+      [expression, dependencyName, lhs, rhs] = deferred = ctx.deferred().shift()
       if ctx.declaration dependencyName
         compiledPairs.push definitionPairCompile ctx, lhs, rhs
       else
         # If can't compile, defer further
-        ctx.addDeferred deferred...
+        ctx.addDeferredDefinition deferred...
       if prevSize is ctx.deferred().length
         deferredCount++
 
   # defer completely current scope
   if _notEmpty ctx.deferred()
-    for [dependencyName, lhs, rhs] in ctx.deferred()
-      ctx.setDeferParent dependencyName
+    for [expression, dependencyName, lhs, rhs] in ctx.deferred()
+      if ctx.isInTopScope()
+        malformed expression, "#{dependencyName} is not defined"
+      else
+        ctx.setDeferParent dependencyName
 
   compiledPairs
 


    #log "ASSIGN #{ctx._name()}", ctx.shouldDefer()
    if ctx.shouldDefer()
      ctx.addDeferred ctx.shouldDefer(), to, expression
      return 'deferred'

    if assigns.length is 0

  isInLateScope: ->
    @_scope().late

  isInTopScope: ->
    @_scope().topLevel

  declaration: (name) ->
    @_declarationInScope @scopes.length - 1, name

