Skip to content

remove named imports - #122

Merged
alii merged 1 commit into
masterfrom
no-named-imports
Sep 24, 2026
Merged

alii merged 1 commit into
masterfrom
no-named-imports

Conversation

@alii

@alii alii commented Sep 23, 2026

Copy link
Copy Markdown
Member

Named imports are gone. import scarlet/list.{fold} no longer parses. There is one way to import a module, and you name what you use through it:

import scarlet/http
import scarlet/net/socket as sock

fn route(req http.Request) http.Response { .. }
Ok(sock.Data(bytes)) -> ..

Parser. A .{..} after an import is one error that says what to write: Import the module and name it at the use: `import scarlet/list`, then `list.fold` . The parser then skips the list and keeps the import, so there's no cascade after it.

Removed with it:

  • ImportDeclaration::items, and the formatter's rendering of it.
  • The compiler's per-item binding.
  • ReferenceKind::ImportItem, and the alias_of chain that made {X as Y} its own rename class.
  • The unused-import rule's item edge.
  • The REPL's item tracking.
  • The tree-sitter import_items rule.
  • The raw frame-slot load: ValueRef::Slot, Load::Slot in scarlet_ir, and FrameSlot.
    • Only item bindings reached it. I checked by making it fail loudly and running the whole suite: the one test that reached it built it by hand.
    • The new VM already refused to load it.
    • resolve_variable now says Place::ThisFunction for a name the function binds, rather than handing out a slot the elaborator never uses.

Migrated:

  • Every .scrl in the repo: the stdlib, the examples, and tests/programs.
    • A throwaway rewrite drove the LSP's own find-references, so a local that shadows an imported name was left alone.
    • Types and constructors were rewritten by name.
    • Every rewritten program passes scarlet check.
    • examples/modules.scrl now shows as on a module, since it used to show item aliases.
  • The inline programs in the Rust tests: about 75 import lines.

Tests:

  • Converted, where the property still holds with qualified names:
    • the constructor-head exhaustiveness and test-ladder cases (now with qualified heads)
    • type-import rollback (now lib.Color)
    • hover and rename through a qualifier
  • Deleted, where it only existed because of named imports:
    • an item alias as a rename class
    • swapped constructor aliases
    • a selective import shadowing a prelude name (env_rollback.rs, so there are 43 test executables now, and the project notes say so)
    • "no member" and "is private" errors at an import item. The qualified versions stay.
  • New: a parser test that a named import is exactly one error, and that it names the right qualifier with and without as.

docs/visibility.md no longer lists selective import as a place visibility is checked. The changeset is major.

All seven CI gates pass locally. hawk ran for the host target, and nothing here is gated on a cfg. bun run corpus failed at first because of a merged branch's worktree left inside the repo. I removed it, and then corpus passed.

@alii
alii merged commit f9f9613 into master Sep 24, 2026
4 checks passed
@alii
alii deleted the no-named-imports branch September 24, 2026 00:46
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