Try putting everything from the opening to the closing set tag all on one line, like this
<Set name="field_name"><If singular type="type_1"> field_1<Else if singular type="type_2" />field_2</If></Set>
Line breaks in HTML are interpreted as spaces, which means that as soon as there’s a line break in the code editor within your Set tag, it’ll save a space into the variable, which means that your loop ends up looking something like this:
<Loop acf_relationship=" field_1 ">
Which I assume wouldn’t work right.
This is just how HTML works so I’m not sure if there’s a way to address this in L&L, but I made a feature request a while back to at least prompt people when there’s a risk that a space character will unintentionally make its way into a variable.
Let me know if that doesn’t solve your issue and I can look a little deeper into this.
Nice catch, you’re right, it works without line breaks.
I tried that already (see above) but didn’t include the <Set> paired tags in the same single line as the conditional.