# cannot use x (variable of type T) as type *T in argument to method

- **ID:** `go/method-receiver-type-mismatch`
- **Domain:** go
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A method with a pointer receiver (*T) is being called with a value receiver (T), or vice versa, and the argument type doesn't match the expected pointer or value type.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| go1.20 | active | — | — |
| go1.21 | active | — | — |
| go1.22 | active | — | — |
| go1.23 | active | — | — |

## Workarounds

1. **Take the address of the variable: method(&x) if the method expects *T** (95% success)
   ```
   Take the address of the variable: method(&x) if the method expects *T
   ```
2. **If the method expects T, dereference the pointer: method(*ptr)** (90% success)
   ```
   If the method expects T, dereference the pointer: method(*ptr)
   ```

## Dead Ends

- **Using a type assertion: x.(*T)** — Type assertion works on interfaces, not on concrete types; it will cause a compile error if T is not an interface. (95% fail)
- **Changing the method receiver to value type (T)** — If the method modifies the struct, changing to value receiver will cause those modifications to be lost. (80% fail)
- **Passing &x directly without checking if x is addressable** — If x is not addressable (e.g., return value of a function), &x will cause a compile error. (75% fail)
