Skip to content

dump failed if there is a nil value #232

@Whirlwind

Description

@Whirlwind

image
I am using Swift 5.1 and Xcode 11.2.1.

I try to debug the Yams, and it throw a error:

private func represent(_ value: Any) throws -> Node {
    if let string = value as? String {
        return Node(string)
    } else if let representable = value as? NodeRepresentable {
        return try representable.represented()
    }
    throw YamlError.representer(problem: "Failed to represent \(value)")  // -> print "Failed to represent nil"
}

extension Optional: NodeRepresentable {
    public func represented() throws -> Node {
        switch self {
        case let .some(wrapped):
            return try represent(wrapped)  // <-- The ALIAS's value hit this case, but it is nil. As it is a .some<nil>
        case .none:
            return Node("null", Tag(.null))
        }
    }
}

Is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions