jordwalke / jordwalke/vim-reasonml

:MerlinTypeOf raises error with some ReasonReact components

Open
#26 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
111
Forks
13
PR merge metrics
No merged PRs in 30d

Description

I just set this up with VimBox, and it seems to be working well except for `:MerlinTypeOf`.

## Steps to reproduce

I'm not sure *exactly* how to reproduce, since occasionally `:MerlinTypeOf` works, but these steps seem to work.

1. Install the project (I'm using bs-platform 7.3)

```sh
bsb -init bs-sample -theme react-starter
cd bs-sample
npm i
```
Create an esy.json
```json
{
"devDependencies": {
"ocaml": "4.6.x",
"@opam/reason": "*",
"@opam/merlin": "*"
}
}
```

```sh
esy install
esy mvim .
npm run start
```

2. It seems to only consistently happen when a component is inside a nested module (I could be wrong). Add this to `src/App.re`:
```reason
module A = {
[@react.component]
let make = () =>

;
};
```

Hover over `make` and type `:MerlinTypeOf`.

## The output

```
Error detected while processing function merlin#TypeOf:
line 4:
Traceback (most recent call last):
File "", line 1, in
File "/Users/x/.esy/3______________________________________________________________/i/opam__s__merlin-opam__c__3.3.4-9cf3482f/share/merlin/vim/autoload/merlin.py", line
627, in vim_type_enclosing
track_verbosity=True
File "/Users/x/.esy/3______________________________________________________________/i/opam__s__merlin-opam__c__3.3.4-9cf3482f/share/merlin/vim/autoload/merlin.py", line
173, in command2
result = json.loads(merlin_exec(cmdline,input=content))
File "/Users/x/.esy/3______________________________________________________________/i/opam__s__merlin-opam__c__3.3.4-9cf3482f/share/merlin/vim/autoload/merlin.py", line
137, in merlin_exec
(response, errors) = process.communicate(input=input)
File "/usr/local/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 964, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/local/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1755, in _communicate
self.stdout.errors)
File "/usr/local/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 841, in _translate_newlines
data = data.decode(encoding, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x84 in position 161: invalid start byte
line 5:
E121: Undefined variable: l:type
E116: Invalid arguments for function 167_ShowTypeEnclosing
```

## Other information

All of the other Merlin features seem to work fine, go-to-location, autocomplete, etc.

Running `:MerlinTypeOf` works fine for other values in the same file, just not `A.make`.

In some modules in another project, running `:MerlinTypeOf` in *any* value inside a component function doesn't work. However I can't figure out the exact steps to reproduce that.

I'm still figuring out my Vim+Reason configuration, so I hope this isn't a user error. I'm happy to provide more information if necessary.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the nested component example in src/App.re and reproduce the failure using :MerlinTypeOf. Read the traceback path in autoload/merlin.py, especially vim_type_enclosing and merlin_exec, then verify that type lookup for A.make completes without the UnicodeDecodeError and displays its type.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml, python, react, vim
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.