Yes, that's a strict dominion rule. Conceptually, the buy phase has 2 subphases.
In the first subphase you generate money by playing Treasures or converting Coffers to coin.
In the second subphase you spend that money, by buying cards, Events or Projects, or repaying debt.
So you see that the when you buy Gamble, you are already in the second subphase. So any Treasures you draw cannot be played any more.
Of course you can play as you like IRL, but then cards as Gamble or March become more powerfull.