Yes, the game works correctly here. The issue is in misunderstanding of the rules (which is the game's fault obviously). Could you help me understand where it comes from, please?
So are you thinking that the level is solved because the character got to the treasure? Or are there any other requirements for considering a level solved? Couldn't you lead the character to the treasure around the trap ignoring it (and the button) entirely?