rescript-lang / rescript-lang/rescript

Uncapitalized cmi path in the error message

Open
#6,914 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
7.5k
Forks
485
Avg merge
1d 2h
Merged PRs (30d)
55

Description

// ABC.resi
type a = X | Y0
// ABC.res
type a = X | Y

The compiler failed to compile and show the message as below:

rescript: [3/3] src/ABC.cmj
FAILED: src/ABC.cmj

  We've found a bug for you!
  /Users/woonki/GitHub/projects/rescript-test2/src/ABC.res:1:1-14

  1 │ type a = X | Y
  2 │ 

  The implementation /Users/woonki/GitHub/projects/rescript-test2/src/ABC.res
  does not match the interface src/aBC.cmi: // ?? aBC.cmi
  Type declarations do not match:
    type a = X | Y
  is not included in
    type a = X | Y0
  /Users/woonki/GitHub/projects/rescript-test2/src/ABC.resi:1:1-15:
    Expected declaration
  /Users/woonki/GitHub/projects/rescript-test2/src/ABC.res:1:1-14:
    Actual declaration
  Fields number 2 have different names, Y and Y0.

FAILED: cannot make progress due to previous errors.

I guess here is the place makes the module name uncapitalized https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/ext/misc.ml#L221-L222

If we change the order of if else as finding the fullname first then ufullname as last would fix this issue, but I don't know the history why finding the uncapitalized file path first instead of original path.

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

Start at jscomp/ext/misc.ml around lines 221-222 and reproduce the ABC.res/ABC.resi mismatch shown in the issue. Trace how the fullname and uncapitalized filename are selected in the error message, then verify that the reported .cmi path preserves the original capitalization. Done when the reproduction no longer shows aBC.cmi.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.