reasonml / reasonml/reason

JSX elements produce different locations depending on component casing

Open
#2,427 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

In <Div /> the "caller" expression in the produced Pexp_apply node does not include the opening bracket <, it goes from characters 1 to 4.

https://astexplorer.net/#/gist/33730f9a7b577408724bb3ef1ad3fc15/8f09a1e175d6020c39a7a8ed9e2158bdfc51b684

But in <div /> it does, it goes from 0 to 4.

https://astexplorer.net/#/gist/33730f9a7b577408724bb3ef1ad3fc15/a0b88ea7cbf094e7ed33f8dc7f96234386fd9a19

This is pretty minor, but affects for example the way IDEs and editors add overlays when hovering over elements. In the second case, the overlay would exceed the name of the component.

I'm not sure if this is expected, I checked the place where I believe these locations are set and they seem to be the same 🤔

https://github.com/facebook/reason/blob/0b44b2d0cc529ce2e4b88d48f15f534fc3306e30/src/reason-parser/reason_parser.mly#L971-L975

Contributor guide

No contributing guide indexed for this repository

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

Compare the two AST Explorer examples for

and and inspect the location-setting logic at src/reason-parser/reason_parser.mly:971-975. Trace why the produced Pexp_apply caller ranges differ by component casing, then verify that both JSX forms produce consistent locations without exceeding the component name.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.