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`
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 {
eprintln("No such typedef node with id " + id)
continue <-- CONTINUE INSTEAD OF PANIC
}
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:72:31:35
|
72 | 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:78:24:41
|
78 | fn get_attribute_value(node xmlc.XMLNode, attribute_name string) -> ?string {
| ^^^^^^^^^^^^^^^^^ (1) parameter declared here as `xmlc.XMLNode`
help: add `.unwrap()` to get value from Option
--> xml.sp:72:35:35
|
72 | name := get_attribute_value(node.unwrap(), "name") or { panic("Typedef node is corrupted - doesn't have name attribute") }
| +++++++++
help: also you can call `.expect(<msg>)`, propagate none with `?` operator or provide default value
with `or {}`, learn more about an Option type in https://example.dev/docs/concepts/error-handling