Subject: bug#49202: guix import go type error (failed regex match?)

From: Sarah Morgensen <[email-masked]>
Date: Thu, 24 Jun 2021 14:20:00 -0700

Sarah Morgensen <[email-masked]> writes:

>
> // When updating replace rules, make sure to also update the rules in integration/client/go.mod
> replace (
> 	// prevent transitional dependencies due to containerd having a circular
> 	// dependency on itself through plugins. see .empty-mod/go.mod for details
> 	github.com/containerd/containerd => ./.empty-mod/
> 	github.com/gogo/googleapis => github.com/gogo/googleapis v1.3.2
> 	// urfave/cli must be <= v1.22.1 due to a regression: https://github.com/urfave/cli/issues/1092
> 	github.com/urfave/cli => github.com/urfave/cli v1.22.1
> 	google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63
> )
>
> Based on the trace it seems like it's treating the k8s.io/utils require
> as a replace directive, but I have no idea why.
>

Looking at this again, I realize I misread the code: the "k8s.io/utils"
etc. is actually the head of the already-parsed requirements list.

Instead, when the error is thrown, we are in replace-directive, which is
called by in-replace...

--8<---------------cut here---------------start------------->8---
  (define (in-replace requirements replaced)
    (let ((line (read-line)))
      (cond
       ((eof-object? line)
        ;; this should never happen here but we ignore silently
        (values requirements replaced))
       ((string=? line ")")
        ;; end of block, coming back to toplevel
        (toplevel requirements replaced))
       (#t
        (call-with-values (lambda ()
                            (replace-directive requirements replaced line))
          in-replace)))))
--8<---------------cut here---------------end--------------->8---

...which does not handle comments. (Even the top-level parser doesn't
explicitly handle comments, it just discards any line that does not
start with "require" or "replace.")

Looks like the parser could use a little more robustness! :)

Hope that helps,
Sarah