fix(semantics): import a re-exported extension member through the re-exporting module #189
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/182-reexported-member-import"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task
Closes #182
What and why
A member re-exported with
public use Text.doubled from "./ext"could not be imported from the re-exporting module:use Text.doubled from "./lib"failed with "Textis not exported by./lib".bindMemberImport(compiler/src/semantics/scope.trb) handed on the re-exporting module's entries with only the span replaced, soentry.pathstayed"./ext".memberImportOfmatches the importer's item by span, the path written in itsuse, and the name, so it found nothing, and the item fell into the export check.The fix:
entry.copy(path: path, span: at)).memberImportOffinds it, and "<path>adds no member ..." names the path written on the importer's line, not the original./ext.useitem owns its entries.bindMemberde-duplicated on package and name, so the item's entry could be dropped when the scope already held one from another item.bindMembersnow replaces the entries at the item's span (inmembers, and inexportedMembersfor apublic use) and reports a change only when they differ, so the fixpoint still ends.acme/otheradds no member ..." for a member that resolves.memberImportOfand the prelude'saddPreludesare unchanged: the prelude's re-exports (public use Int64.seconds from "std/time") are still added after the fixpoint, de-duplicated on package and name.Test
New tests in
compiler/tests/check.test.trb, group "Modules", in themessages(files)style of the existing member-import tests:extextendsTextwithdoubled,libre-exports it,mainimports it from./liband calls it: no problems.main->lib->mid->ext), imported withas twiceand called asvalue.twice(): no problems.use Text.doubled from "acme/other",other/src/lib.trbre-exporting from./ext): no problems.acme/otherre-exports fromacme/third), imported byapp: no problems. This covers the replacement of the first pass's entry../libadds no membertripledtoText" at the importer'suseline (span 9..16 ofmain.trb). This holds both whenlibdoes not re-export the member and whenlibre-exports one that./extdoes not add.The issue's fixture uses
Bytes. The test workspace's prelude has noBytes, so the tests extendText, which is the same case. The existing member-import tests and the prelude tests are unchanged.Locally:
torb format(today's nightly) on the two touched files. Check, format and the suite run in the forge CI (tier A; tier B is not required because nothing undercompiler/src/ir,backendorruntimechanged).Seed: no. There is no syntax change, no new native, no driver flag, and no std name looked up by string.
CI round 1 (run 225): tier A red only on
format --checkof the two touched files (two command calls, one blank line);test compiler/tests (native)passed. Fixed in the same commit.053c25cb4adafc0b2808Checklist for
dafc0b2:check.test.trbcover one hop, two hops withas, the package path, a package re-exporting from its own dependency (the first-pass replacement), and the "adds no member" regression with the span at the importer'suseline. CI green for this head (tier A, bootstrap, gates).entry.copy(path: path, span: at)letsmemberImportOfmatch the importer's item.replacedAtcompares as sets and reports a change only on a difference, so the fixpoint still ends. Entries are replaced per span within one module's scope, so items cannot clobber each other.scope.trband its test file are touched.Non-blocking: the test uses
Textrather than the issue'sBytes, and the PR body explains why; fine.