;
} elseif ($this->getNode('node') instanceof Twig_Node_Expression_GetAttr) {
$this->getNode('node')->setAttribute('is_defined_test', true);
- $compiler->subcompile($this->getNode('node'));
+ $compiler
+ ->raw('null !== ')
+ ->subcompile($this->getNode('node'))
+ ;
} else {
throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
}
{{ foobar is not defined ? 'ok' : 'ko' }}
{{ nested.foo is defined ? 'ok' : 'ko' }}
{{ nested.bar is not defined ? 'ok' : 'ko' }}
+{{ nested.zero is defined ? 'ok' : 'ko' }}
--DATA--
-return array('foo' => 'bar', 'bar' => null, 'nested' => array('foo' => 'foo'));
+return array('foo' => 'bar', 'bar' => null, 'nested' => array('foo' => 'foo', 'zero' => 0));
--EXPECT--
ok
ok
ok
ok
ok
+ok