type = fr_table_value_by_str(fr_type_table, type_name, FR_TYPE_VOID);
fr_assert(type != FR_TYPE_VOID);
- if (type == FR_TYPE_NULL) type = da->type;
+ if (type == FR_TYPE_NULL) {
+ type = da->type;
+
+ } else if (fr_type_is_leaf(type) != fr_type_is_leaf(da->type)) {
+ incompatible:
+ cf_log_err(cs, "Incompatible data types in foreach variable (%s), and reference being looped over (%s)",
+ fr_type_to_str(type), fr_type_to_str(da->type));
+ goto fail;
+
+ } else if (fr_type_is_structural(type) && (type != da->type)) {
+ goto incompatible;
+ }
variable_name = cf_section_argv(cs, 1);