* @todo - the output type could be larger than the input type, if the shift is
* more than the input type can handle. e.g. uint8 << 4 could result in uint16
*/
- case T_RSHIFT:
case T_LSHIFT:
+ if (!fr_type_is_integer(a->type)) {
+ return handle_result(a->type, T_LSHIFT, ERR_INVALID);
+ }
+
+ if (hint != FR_TYPE_NULL) break;
+
+ if (fr_type_is_signed(a->type)) {
+ hint = FR_TYPE_INT64;
+ break;
+ }
+ hint = FR_TYPE_UINT64;
+ break;
+
+ case T_RSHIFT:
hint = a->type;
break;
default:
- return ERR_INVALID;
+ return handle_result(a->type, T_LSHIFT, ERR_INVALID);
}
} while (0);
xlat_expr &Packet-Src-IP-Address =~ /%{Packet-Dst-IP-Address}/
match true
-# @todo - failure?
+# Auto upcast
xlat_expr (uint32) 1 << 32
-match NULL
-#match ERROR expanding xlat: Value overflows 'uint32' when calculating result.
+match 4294967296
+
+#
+# The error message is currently "eaten" by a call to RPEDEBUG
+# in xlat_eval.c. Oh well.
+#
+xlat_expr (uint32)((uint32) 1 << 32)
+match ERROR expanding xlat:
#
# This shifts it 8, and then tries to cast it to uint8?
#
xlat_expr (uint8) 1 << 8
-match NULL
-#match ERROR expanding xlat: Value overflows 'uint8' when calculating result.
+match 256
# Cannot perform any operations for destination type ether
xlat_expr 00:01:02:03:04:05 ^ 11:22:33:44:55:66