Skip to content

Documentation for incremental module definitions#1087

Open
Gustavo2622 wants to merge 2 commits into
mainfrom
doc-module-update
Open

Documentation for incremental module definitions#1087
Gustavo2622 wants to merge 2 commits into
mainfrom
doc-module-update

Conversation

@Gustavo2622

Copy link
Copy Markdown
Contributor

This adds documentation for the incremental / fine-grained module definition syntax / functionality.

It depends on #1086

…ases

`module M' = B with {...}` re-rooted references using only the TOP path
of the base mpath, appending the reference's arguments to the
destination's.  Consequences:

- a sub-module base P.O had every P-rooted reference re-rooted onto M':
  the enclosing module's state (P.g -> M'.g) and even the sub-module's
  own state (P.O.x -> M'.O.x) became dangling globals, silently changing
  the program's semantics while remaining fully usable by the program
  logics;
- a functor base F(A) whose body contains self-calls crashed the
  elaborator (assertion failure in EcEnv.Fun.by_xpath): the self-call
  F(A).h, unsuspended at A, was rewritten to M'(A).h with M' not a
  functor.

The substitution entry now records the full base expression (top path,
arguments, inner path) and rewrites a reference iff it lies at or below
the base's inner path AND its arguments extend the base's (references
to program variables carry no arguments); the remainders are
transplanted onto the destination.  Non-matching references (an
enclosing module's state, sibling sub-modules, other applications)
denote state that is not copied along with the base's items, and are
left untouched.

This makes updates of sub-modules (P.O), applied functors (F(A)), and
sub-modules of applied functors (F(A).O) all well-defined: the base's
items are copied, everything else is shared, and the application is
baked into the copy.  Behavior for plain top-level bases and for
section-exit alias inlining is unchanged (empty argument and inner-path
components).

Also: reject abstract-module bases with a proper error instead of an
assertion, and add regression tests covering every base shape.
Adds doc/language/module-update.rst, documenting `module M' = M with
{...}`: syntax, the copy/share semantics, restrictions, and worked
examples (ghost-state instrumentation, statement and result rewrites,
loop edits, match-branch collapse, functor and sub-module updates).

The code-position language (shared by the program tactics and by module
updates) is factored out into its own page,
doc/language/code-positions.rst, which module-update.rst references.

The section on sub-module and applied-functor bases documents the
semantics introduced by the parent commit (sound module updates on
sub-module and applied-functor bases); its example is executable and
mirrors the regression tests in tests/module-update-bases.ec.  This
change is meant to be merged after that fix.

Both pages are marked :orphan: until a language-reference toctree
lands.
@Gustavo2622
Gustavo2622 marked this pull request as ready for review July 24, 2026 11:28
@fdupress

Copy link
Copy Markdown
Member

Change the target branch to avoid the commit count failure. The target will automatically change when we merge the other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants