                     throw TomlError.SyntaxError("Table name must not be blank")
                 }
 
-                if toml.hasKey(keyPath) || toml.hasTable(keyPath) {
+                let keyPathStr = String(describing: keyPath)
+                if toml.hasKey(keyPath) || declaredTables.contains(keyPathStr) {
                     throw TomlError.DuplicateKey(String(describing: keyPath))
                 }
 
-                toml.setTable(key: keyPath)
+                declaredTables.insert(keyPathStr)
                 let tableTokens = extractTableTokens(tokens: &tokens)
                 try parse(tokens: tableTokens)
                 tableExists = true

            } else if case .Identifier(let val) = subToken {
                emptyTableSep = false
                keyPath.append(val)
            }
        }


class Parser {
    var keyPath: [String] = []
    var currentKey = "."
    var declaredTables = Set<String>()
    var toml: Toml = Toml()

    // MARK: Initializers
