Skip to content

Wrong .glob offsets for references from accumulated .elpi files #1079

Description

@yoshihiro503

When a .v file accumulates an external .elpi file (via Extra Dependency

  • Elpi Accumulate File) and that .elpi file contains a Coq term
    quotation (e.g. {{ nat }}) that gets elaborated, the R (reference) entry
    written to the .v file's .glob uses the byte offset of the identifier
    inside the .elpi file, not inside the .v file. The two files have
    unrelated contents/lengths, so the recorded span is either garbage or, as in
    the example below, entirely out of range for the .v file.

This breaks any tool that relies on .glob offsets being valid spans of the
.v file the entry is attributed to (coqdoc-style HTML generation,
"jump to definition" in editors, etc.).

Environment

  • Rocq: 9.1.1
  • rocq-elpi: upstream/master @ 5ad969a4

Minimal reproduction

mylib.elpi

main _ :- T = {{ nat }}, coq.say T.

test.v

From elpi Require Import elpi.
From Repro Extra Dependency "mylib.elpi" as mylib.
Elpi Command mytest.
Elpi Accumulate File mylib.
Elpi mytest.
$ rocq compile -R . Repro -dump-glob test.glob test.v
$ cat test.glob
DIGEST NO
FRepro.test
R25:28 elpi.elpi <> <> lib
R17:19 Corelib.Init.Datatypes <> nat ind

R17:19 claims that bytes 17–19 of test.v reference nat. But it is a part of "Import" (" I").
The offset is really the position of nat inside mylib.elpi, not test.v.

Related links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions