Repository: servo/servo
File: components/script/dom/webgl/webglprogram.rs (Rust)

Code before:
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("detachShader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(Some(shader));

                Ok(())
            },
            Err(e) => Err(e),
        }
    }

    /// glDetachShader
    pub(crate) fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
        match self.droppable.borrow_mut().detach_shader(shader) {
            Ok(shader) => {
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("detachShader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(None);

                Ok(())
            },
            Err(e) => Err(e),
        }
    }

    /// glBindAttribLocation
    pub(crate) fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> {
        if self.is_deleted() {
            return Err(WebGLError::InvalidOperation);
        }

        if !validate_glsl_name(&name)? {
            return Ok(());
        }
        if name.starts_with_str("gl_") {
            return Err(WebGLError::InvalidOperation);
        }


Review comment (suggestion):
```suggestion
                        error!("detach_shader: Unexpected shader type");
```

Code after:
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(Some(shader));

                Ok(())
            },
            Err(e) => Err(e),
        }
    }

    /// glDetachShader
    pub(crate) fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
        match self.droppable.borrow_mut().detach_shader(shader) {
            Ok(shader) => {
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("detach_shader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(None);

                Ok(())
            },
            Err(e) => Err(e),
        }
    }

    /// glBindAttribLocation
    pub(crate) fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> {
        if self.is_deleted() {
            return Err(WebGLError::InvalidOperation);
        }

        if !validate_glsl_name(&name)? {
            return Ok(());
        }
        if name.starts_with_str("gl_") {
            return Err(WebGLError::InvalidOperation);
        }

        self.upcast().send_command(WebGLCommand::BindAttribLocation(
            self.id(),
            index,
            name.into(),
        ));