R() and e() bug

No, this is not a bug. r() and e() are functions to which you are passing arguments. And in the example above, the second argument ($var) is not defined and therefore, you get the error. That is, the expression is not evaluated within the parentheses, but only in the return statement.

In this case, the alternative to a standard if statement is using the ternary operator:

<?php echo isset($var)? $var: null; ?>

e() will only work if you pass a known variable or a string:

<?php e(isset($var), 'blue', 'black'); ?>
<?php
$var = 'red';
e($var == 'blue', $var, 'black'); 
?>