Do black puddings corrode slashing weapons

Black puddings are immune to slashing damage, and the Corrosive Form trait states:

… Any nonmagical weapon made of metal or wood that hits the pudding corrodes. After dealing damage, the weapon takes a permanent and cumulative-1 penalty to damage rolls. …

The bit that confuses me is "after dealing damage". If the pudding is immune to slashing damage, then slashing weapons will never deal damage, and thus should not take the -1 penalty. However, that seems to contradict the previous statement, that anything that hits will corrode.