Skip to content

Compile a type that came from another module - #885

Merged
onatozmenn merged 1 commit into
mainfrom
backend-imported-types
Aug 2, 2026
Merged

Compile a type that came from another module#885
onatozmenn merged 1 commit into
mainfrom
backend-imported-types

Conversation

@onatozmenn

Copy link
Copy Markdown
Collaborator

Follow-up to #882. A call could cross a module boundary and a type could not, so a program that imported a record, a choice, an effect or a handler was refused however plain the call using it was.

A type crosses the same way a function does, and the thing that matters is that it comes out as what the module that declared it built. Two layouts for one record would make a value of it fit neither, so each module's tables gain the names its use lines asked for rather than a copy of the shape. By name and only for what was asked for, so two modules that both declare a Point keep their own.

The checker carries an imported type by module and name rather than by definition, for the same reason a DefId can't cross at all, and the lowering had no arm for that shape. It has one now, and the name is enough because the borrowing above put the right layout under it.

The agreement test reads a field of a record the other module built and matches on a variant of a choice the other module declared, which is what would break if the two sides disagreed on the layout.

Part of #877.

Written with AI assistance.

A call could cross a boundary and a type could not, so a program that
imported a record, a choice, an effect or a handler was refused however
plain the call using it was.

A type crosses the same way a function does, and what matters is that it
comes out as what the module that declared it built. Two layouts for one
record would make a value of it fit neither, so each module's tables gain
the names its `use` lines asked for rather than a copy of the shape. By
name and only for what was asked for, so two modules that both declare a
`Point` keep their own.

The checker carries an imported type by module and name rather than by
definition, for the reason a `DefId` cannot cross at all, and the
lowering had no arm for that shape. It has one now, and the name is
enough because the borrowing above put the right layout under it.

Part of #877.
@onatozmenn
onatozmenn merged commit 984ceab into main Aug 2, 2026
5 checks passed
@onatozmenn
onatozmenn deleted the backend-imported-types branch August 2, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant