Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:MerlinTypeOf raises error with some ReasonReact components #26

Open
johnridesabike opened this issue May 25, 2020 · 1 comment
Open

Comments

@johnridesabike
Copy link

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)
bsb -init bs-sample -theme react-starter
cd bs-sample
npm i

Create an esy.json

{
  "devDependencies": {
    "ocaml": "4.6.x",
    "@opam/reason": "*",
    "@opam/merlin": "*"
  }
}
esy install
esy mvim .
npm run start
  1. It seems to only consistently happen when a component is inside a nested module (I could be wrong). Add this to src/App.re:
module A = {
  [@react.component]
  let make = () => <div />;
};

Hover over make and type :MerlinTypeOf.

The output

Error detected while processing function merlin#TypeOf:
line    4:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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 <SNR>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.

@johnridesabike
Copy link
Author

After some digging, I think this may be outside the scope of vim-reasonml, and may be a larger issue with Merlin and BuckleScript ocaml/merlin#617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant