Skip to content

Better type in error conected to usage of Options #17

Description

@ArtemkaKun
type xmlc.XMLNode = unsafe &void

for id in ids {
        mut node := none as ?xmlc.XMLNode

        for potential_node in nodes {
            if get_attribute_value(potential_node, "id") == id {
                node = potential_node
                break
            }
        }

        if node == none {
            panic("No such typedef node with id " + id)
        }
        
        name := get_attribute_value(node, "name") or { panic("Typedef node is corrupted - doesn't have name attribute") }
}
error(E0050): cannot pass `?xmlc.XMLNode` to parameter with `xmlc.XMLNode` type
 --> xml.sp:71:31:35
    |
 71 |       name := get_attribute_value(node, "name") or { panic("Typedef node is corrupted - doesn't have name attribute") }
    |                                   ^^^^ expected: unsafe &void, got: ?xmlc.XMLNode

note: parameter has `xmlc.XMLNode` type
 --> xml.sp:77:24:41
    |
 77 | fn get_attribute_value(node xmlc.XMLNode, attribute_name string) -> ?string {
    |                        ^^^^^^^^^^^^^^^^^ (1) parameter declared here as `xmlc.XMLNode`

Line ^^^^ expected: unsafe &void, got: ?xmlc.XMLNode should be ^^^^ expected: xmlc.XMLNode, got: ?xmlc.XMLNode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions