Errors when creating materials with code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zakarya
func change_color(color):
   var material =
   material.albedo_color = color
   set_surface_override_material(3, material)

This code changes the accent color of a mesh. It works just fine, but it throws four errors whenever you run this function.

material_casts_shadows: Condition "!material" is true. Returning: true
material_is_animated: Condition "!material" is true. Returning: false
material_get_instance_shader_parameters: Condition "!material" is true.
material_update_dependency: Condition "!material" is true.

I’m very confused. It doesn’t crash or anything, and the color changes like it is supposed to.