Skip to content

Imported files answer to their file name as well as to their alias, so one prefix can point at two files #1184

Closed

Description

@olety

What you did

BEND_NO_TELEMETRY=1 bend main.bend --verdict on the two-file layout below, then on the four-file layout.

What happened

Two files. main.bend imports ./X.bend under the alias Z, and never declares an alias X. Still, X.f resolves:

$ bend main.bend --verdict
ALL PROOFS CHECK

Renaming X.bend to real.bend (keeping as Z) gives the expected expected : a defined name / observed : X.f. So the file name is acting as a namespace prefix, independently of the alias.

Four files. main.bend aliases ./q.bend as X. Another import (y.bend) loads ./X.bend under as Z. In main.bend, X.M names q.bend's def and X.f names X.bend's def at the same time: the file-name namespace and the user alias merge. A reader of main.bend sees import ./q.bend as X and a claim about X.f, and assumes the wrong file.

The guide says "The alias is local to the importing file" (guide/GUIDE.md, imports section), which this contradicts. The emitted BendTT carries the real X.f with its real body, so the kernel checks the right thing; this is a name-resolution issue, not a soundness one.

Same result on 2.0.32 and on main at 777ee0b (2.0.34), run as bun bend2/main.ts.

The file

Two-file case:

# X.bend
import Base

def f(a: Nat) -> Nat:
  0n
# main.bend
import Base
import ./X.bend as Z

def go() -> {X.f(1n) == 0n: Nat}: {==}

def main() -> Nat:
  0n

Four-file case (X.bend as above):

# q.bend
import Base

def M() -> Nat:
  9n
# y.bend
import Base
import ./X.bend as Z

def W() -> Nat:
  0n
# main.bend
import Base
import ./q.bend as X
import ./y.bend as Y

def go() -> {X.f(1n) == 0n: Nat}: {==}

def main() -> Nat:
  X.M()

bend --version

bend 2.0.32 (also main 777ee0b / 2.0.34)

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 21.0.0 (clang-2100.3.20.102)

Activity

  1. added
    bug
    on Sep 29, 2026
  2. olety commented on Sep 29, 2026

    @olety
    Author

    Diagram

    diagram. From the token X.f in main.bend two paths leave. Grey, labelled EXPECTED (guide): X is the alias ''as X'' = q.bend; q.bend has no f; should say expected : a defined name / observed : X.f. Rose, labelled ACTUAL (compiler): X is the file name X.bend, loaded by y.bend as Z; def f found; actually says ALL PROOFS CHECK. Footer: in the same run X.M() runs q.bend's M (9n) and X.f finds X.bend's f — one prefix X, two files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions