It looks like you were trying to take advantage of bug behavior which has now been fixed. A summary of commands that worked wrong before but work correctly now are in:
https://forums.mirc.com/ubbthreads....-in-an-identifier-breaks-vars#Post269305

While you can create the command string inside the $iif, it should not be evaluated inside there. What's you're seeing now is that the string inside the $iif is being created as it should be, including evaluating the %variable into its contents, and the error is that when the string is being evaluated there is no %word like there should be.

The correct syntax you should have been using is in testfail2.

Code
alias testfail {
  unset %bleh
  $iif(!%bleh,set -su1 %bleh $scriptline,echo -a is set) 
}
alias testfail2 {
  unset %bleh
  $iif(!%bleh,set -su1 % $+ bleh $scriptline,echo -a is set) 
}
alias testfail3 {
  unset %bleh
  var %bleh 1 | echo -a test1 = $iif(!%bleh,set -su1 %bleh $scriptline,echo -a %bleh is set)
  unset %bleh | echo -a test2 = $iif(!%bleh,set -su1 %bleh $scriptline,echo -a %bleh is set) 
  echo -a result: %bleh
}


I added the -s switch to more easily see when the variable is being set, and use the -u1 switch to ensure the variable doesn't get written to disk as part of a normal save of variables to disk, with the risk that mIRC crashes before the ON EXIT event can do cleanup.