The reasons why you don't get an error without amsmath are mainly accidental related to the fact that in that case you get the TeX primitive argument scanning which differs from the way macro arguments are scanned.