Skip to content

import: a segment starting with a digit is refused, but the error says digits are allowed #1961

Closed

Description

@adeerkhan

Bend 2.0.38 (also observed with the 2.0.39 notice).

Reproduction

mkdir -p sub/2d sub/d2
printf "def value() -> F32:\n  1.0\n" > sub/2d/main.bend
cp sub/2d/main.bend sub/d2/main.bend

printf "import Base\nimport sub/2d/main.bend as M\n\ndef main() -> IO(Unit):\n  do IO<Unit>:\n    IO.print(F32.show(M.value()))\n    return Unit{}\n" > probe_2d.bend
printf "import Base\nimport sub/d2/main.bend as M\n\ndef main() -> IO(Unit):\n  do IO<Unit>:\n    IO.print(F32.show(M.value()))\n    return Unit{}\n" > probe_d2.bend

Observed

bend probe_2d.bend:

SOME PROOFS FAIL
Error:
- expected : an import path of plain names (letters, digits, _ and -; the hub*s files import the hub*s)
- observed : (sub/2d/main.bend)

bend probe_d2.bend prints 1.

What the rule appears to be

A path segment must start with a letter or _. d2 passes, 2d does not. The message lists digits as valid in a name, which sends the reader looking for a path or permission problem instead of renaming the directory.

Proposed

Either accept 2d (it is letters and digits), or change the message to say that each segment must start with a letter or _, and add a Note pointing at the segment and the first character. The restriction itself is fine; the diagnostic is the issue.

This is a diagnostics defect, not a capability gap: renaming 2d to two_moons fixed it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions