   for {name, id, type} in definedNames
     deps = ctx.deferredNames()
 
-    # TODO: this is because functions might declare arity before being declared
-    if not ctx.isCurrentlyDeclared name
+    # Name clash
+    if (ctx.isFinallyDeclaredCurrentlyTyped name)
+      malformed ctx, pattern, "#{name} is already declared"
+    else if not ctx.isCurrentlyDeclared name
+      # TODO: this is because functions might declare arity before being declared
       ctx.declare name, id: id
     if deps.length > 0
       # log "adding top level lhs to deferred #{name}", deps

  isFinallyCurrentlyDeclared: (name) ->
    (@_declarationInCurrentScope name)?.final

  isTyped: (name) ->
    !!@type name


  if ctx.isPreTyped name
    # TODO: unify explicit types like in inferType
    explicitType = ctx.preDeclaredType name
  ctx.preDeclare name,
    id: id
    type: explicitType
    docs: extractDocs docs
  explicitType

preDeclarePatterns = (ctx, patterns) ->
