semantic: Correctly replace typeofs in variables.