﻿# V8040\. The value of the variable is overwritten before it is used\.

The analyzer has detected a variable whose value was overwritten before it was used\.

The example:

```cpp
func createUser(req *http.Request) error {
  user, err := parseUser(req)
  if err != nil {
    return err
  }

  err = validateUser(user)
  err = saveUser(user)

  return err
}
```

The return value of the `validateUser` function is assigned to the `err` variable\. On the next line, a new value is assigned to the same variable\. This means that the result of `validateUser` was not handled\.

To fix this, add a check for the `err` variable immediately after assigning it the return value of `validateUser`:

```cpp
func createUser(req *http.Request) error {
  user, err := parseUser(req)
  if err != nil {
    return err
  }

  err = validateUser(user)

  if err != nil {
    return err
  }

  err = saveUser(user)

  return err
}
```