If it is open source code, then usually the requirement is that you produce the source code for the software that you release. Exactly for the software that you release. For example if you took open source software X, and added feature Y, and distributed the combined software outside your company, anyone can request the source code for X including Y. Handing them the source code for X only wouldn't meet the open source requirements.
Now all this is not illegal, but it means the copyright holder of X could sue you for copyright infringement. They will do that if they have enough reasons to do so. So let's say you are continuously developing your software and occasional hand out your compiled software. Say you built versions 100, 101, 102, 103, 104 of the software, you gave versions 100 and 103 to customers, and anyone asking for the source code is given the source code for the latest, slightly improved version 104.
The copyright holder of X might sue you but: 1. They wouldn't know you are doing this. 2. A judge might side with you and decide that newer, improved source code is good enough (I don't know this, but it seems not unreasonable). 3. The copyright holder might decide that they don't want to sue you for this because you are close enough to meeting the requirements.