Spot the bug in the errors.As target

from Error wrapping
Go 1.27 intermediate 4 min 1 issue to find

Find why this generated program panics instead of printing true.

Go
package main

import (
    "errors"
    "fmt"
)

type ParseError struct{ Input string }

func (e *ParseError) Error() string {
    return "invalid input: " + e.Input
}

func main() {
    err := fmt.Errorf("import: %w", &ParseError{Input: "x"})
    var target ParseError
    fmt.Println(errors.As(err, &target))
}
Open in playground
Report an error