remove warning about unused function check_element. Add a check of valid types when array element is a target of assignment.