This spec code compiles correctly:
fail("bad") if node.nil? hr = node.xpath_node("hr")
The compiler does not complain that Nil#xpath_node does not exist.
However, this code fails to compile:
node.should_not be_nil hr = node.xpath_node("hr")
It barfs “Error: undefined method ‘xpath_node’ for Nil (compile-time type is (XML::Node | Nil))”
Apparently the type inference system sees that
fail("bad") if node.nil? eliminates the Nil type from subsequent uses of
node, but the equivalent line
node.should_not be_nil does not.
Is this a bug? and should I report it to the proper authorities?