leanprover / leanprover/lean4

Misleading import error message when imports are duplicated with different casing

Open
#2,768 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Description
import Std.Data.BitVec.Basic
import Std.Data.Bitvec.Basic -- ``Bitvec`` should have been ``BitVec``

Fails with

import Std.Data.Bitvec.Basic failed, environment already contains 'Std.BitVec.smod._cstage1' from Std.Data.BitVec.Basic

while it should have done nothing, or it should have failed with

no such file or directory (error code: 2): ....../Std/Data/Bitvec/Basic.lean

Note that import Std.Data.Bitvec.Basic alone does not fail, so it could be the case that there are two files, one importing BitVec and another importing ``Bitvec```. Both file would successfully build, but when another file imports both files, the above error would occur. Such behavior could be confusing.

Versions

Lean (version 4.2.0-rc4, commit 819b5eaceaa4, Release)
Ubuntu 20.04.6 LTS(WSL)
Std4: ab21923ce1717d48a8d3d17e77bf6cdd3122eed8

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the two imports shown in the report, and compare it with importing the misspelled path alone. Trace the import-resolution and duplicate-environment handling involved; done means the casing mistake produces the intended missing-file error or is safely ignored rather than a misleading duplicate-environment error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.