I can reproduce this. It only occurs when the gun turret has ammunition loaded. Save file is available, but this is easy to reproduce:
1) Start new game
2) /c game.player.cheat_mode=true
3) /c for name, recipe in pairs(game.player.force.recipes) do recipe.enabled = true end
4) Place a gun turret and load ammunition
5) Create an upgrade plan that replaces gun turrets with laser turrets
6) Attempt to upgrade gun turret