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

bs-platform 5.1.0 incompatibility breaks reason-vscode or lsp #320

Open
sync opened this issue Aug 17, 2019 · 36 comments
Open

bs-platform 5.1.0 incompatibility breaks reason-vscode or lsp #320

sync opened this issue Aug 17, 2019 · 36 comments

Comments

@sync
Copy link

sync commented Aug 17, 2019

When upgrading to bs-platform 5.1.0 on a ReasonReact project for example when opening this project using vscode:

https://github.com/sync/reason-graphql-demo

I get the follow error:

Request textDocument/documentSymbol failed.
  Message: Failed to load /Users/anthonymittaz/Projects/Reason/hackerz/node_modules/.lsp/App-Hackerz.cmt as a cmt w/ ocaml version 402, error: /Users/anthonymittaz/Projects/Reason/hackerz/node_modules/.lsp/App-Hackerz.cmt
is not a compiled interface
  Code: -32603

See attached debug log
debug.log

@sync
Copy link
Author

sync commented Aug 17, 2019

Tried to remove node modules and reinstall everything with:

rm -rf node_modules && yarn

or tried to remove .node_modules/.lsp but neither had an effect

@bobzhang
Copy link
Contributor

bobzhang commented Aug 19, 2019

This line may be relevant, I wonder what kind of internals does RLS rely on Buckle so that we can add some tests on the CI
I would also be interested in how do you assemble the command line args on rls side ( there are some undocumented utils so that you can get it directly from bsb without guessing from .merlin files)

➡️ running bsc /Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/@types' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/__mocks__' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/utils' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/utils/fixtures' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/components' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/components/__tests__' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/__tests__' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/__tests__/pages' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/shims' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/bindings' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/src/helpers' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/pages' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/lib/bs/pages/api' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/bs-platform/lib/ocaml' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/re-classnames/lib/bs/src' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/reason-react/lib/bs/src' -I '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -bs-package-name reason-graphql-demo -bs-package-output es6:node_modules/.lsp -ppx '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/graphql_ppx/ppx' -ppx '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/get_in_ppx/ppx' -ppx '/Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 3' -nostdlib -w -30-40+6+7+27+32..39+44+45+101+A-48 -bs-re-out -impl /Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/.lsp/Index.ast with pwd /Users/anthonymittaz/Projects/Presentations/reason-graphql-demo
Now loading /Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/.lsp/Index.cmt
Size 3556
Sending response {"id": 4, "jsonrpc": "2.0", "error": {"code": -32603, "message": "Failed to load /Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/.lsp/Index.cmt as a cmt w/ ocaml version 402, error: /Users/anthonymittaz/Projects/Presentations/reason-graphql-demo/node_modules/.lsp/Index.cmt\nis not a compiled interface"}}

@jaredly
Copy link
Owner

jaredly commented Aug 19, 2019

hmmm is bs-platform 5.1.0 no longer on ocaml 4.02?

@bobzhang
Copy link
Contributor

bobzhang commented Aug 20, 2019 via email

@bobzhang
Copy link
Contributor

bobzhang commented Aug 22, 2019 via email

@sync
Copy link
Author

sync commented Aug 23, 2019

@jaredly how can i help ?

@hamza0867
Copy link

In my case I get this error :
Fatal error: exception Failure("Error \"Reached end of file without being done parsing\" at 0:1 -> \n") Raised at file "stdlib.ml", line 33, characters 17-33

@sync
Copy link
Author

sync commented Aug 25, 2019

for a repro you can check this: sync/reason-graphql-demo@e207233

@jaredly
Copy link
Owner

jaredly commented Aug 25, 2019

Ok, I've pushed a branch w/ a repro in reason-language-server, along with some extra debug output. https://github.com/jaredly/reason-language-server/tree/diagnose-5.1.0
To repro the error, run esy && esy cp-test && ./ExamplesTests.exe.

This demonstrates first 5.0.6 working, and then 5.1.0 failing.

Here's the invocation that bsc chokes on:

/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c \
-I '/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/lib/bs' \
-I '/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/lib/bs/src' \
-I '/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' \
-I '/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' \
-I '/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' \
-bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate \
-ppx '/Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' \
-nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out \
-impl /Users/jared/clone/tools/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.ast

it exits w/ error code 2, and the following stderr

File "", line 1:
Error: I/O error: : No such file or directory

However, all of the referenced paths in that command exist.
@bobzhang @sync does that help narrow down what's happening?

@bobzhang
Copy link
Contributor

looking into it

@bobzhang
Copy link
Contributor

bobzhang commented Aug 25, 2019

@jaredly how do you assemble the command line flags, -impl is an internal option, it is not needed any more. The extension *.ast also seems weird, it is a format created by you internally?

xx00>bsb -- -t commands src/demo.cmj
/Users/hongbozhang/git/bucklescript/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always  -o src/demo.mlast -bs-syntax-only -bs-binary-ast /Users/hongbozhang/git/xx00/src/demo.ml
/Users/hongbozhang/git/bucklescript/lib/bsb_helper.exe -hash 138916fd68ea48b09eb00565dc2b654d  -g 0 src/demo.mlast
/Users/hongbozhang/git/bucklescript/lib/bsc.exe -nostdlib -bs-package-name xx00  -bs-package-output commonjs:src -color always -bs-suffix -I src -I /Users/hongbozhang/git/xx00/node_modules/bs-platform/lib/ocaml -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101  -o src/demo.cmj src/demo.mlast

@bobzhang
Copy link
Contributor

bobzhang commented Aug 25, 2019

Here is the log I got, it seems we need have a better way to support rls, let me know what kind of internals API rls needs

reason-language-server>./ExamplesTests.exe 
Checking each example project to make sure we can analyze each source file...
# Example bs-5.0.6
Running npm install in /Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6
  Project directory in /Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6
Setting log location: /Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/example-lsp-debug.log
  Source directory /Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src
Analyzing file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src/Component2.re
  Good: file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src/Component2.re
Analyzing file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src/Component1.re
  Good: file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src/Component1.re
Analyzing file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src/Index.re
  Good: file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.0.6/src/Index.re
# Example bs-5.1.0
Running npm install in /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0
  Project directory in /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0
Setting log location: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/example-lsp-debug.log
  Source directory /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src
Analyzing file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src/Component2.re
  Invalid compilation result: Command /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate -ppx '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' -nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out -impl /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.ast errored, with the following output:

File "", line 1:
Error: I/O error: : No such file or directory
and then tried to load the cmt, but got
Failed to load /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.cmt as a cmt w/ ocaml version 402, error: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.cmt
is not a compiled interface
Analyzing file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src/Component1.re
  Invalid compilation result: Command /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate -ppx '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' -nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out -impl /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component1-ReactTemplate.ast errored, with the following output:

File "", line 1:
Error: I/O error: : No such file or directory
and then tried to load the cmt, but got
Failed to load /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component1-ReactTemplate.cmt as a cmt w/ ocaml version 402, error: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component1-ReactTemplate.cmt
is not a compiled interface
Analyzing file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src/Index.re
  Invalid compilation result: Command /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate -ppx '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' -nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out -impl /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Index-ReactTemplate.ast errored, with the following output:

File "", line 1:
Error: I/O error: : No such file or directory
and then tried to load the cmt, but got
Failed to load /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Index-ReactTemplate.cmt as a cmt w/ ocaml version 402, error: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Index-ReactTemplate.cmt
is not a compiled interface

## Tests failed! ##
- Failed to get compilation info for file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src/Index.re : Command /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate -ppx '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' -nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out -impl /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Index-ReactTemplate.ast errored, with the following output:

File "", line 1:
Error: I/O error: : No such file or directory
and then tried to load the cmt, but got
Failed to load /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Index-ReactTemplate.cmt as a cmt w/ ocaml version 402, error: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Index-ReactTemplate.cmt
is not a compiled interface
- Failed to get compilation info for file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src/Component1.re : Command /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate -ppx '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' -nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out -impl /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component1-ReactTemplate.ast errored, with the following output:

File "", line 1:
Error: I/O error: : No such file or directory
and then tried to load the cmt, but got
Failed to load /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component1-ReactTemplate.cmt as a cmt w/ ocaml version 402, error: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component1-ReactTemplate.cmt
is not a compiled interface
- Failed to get compilation info for file:///Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/src/Component2.re : Command /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsc.exe -c -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/reason-react/lib/bs/src' -I '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -open ReactTemplate -ppx '/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 2' -nostdlib -w -30-40+6+7+27+32..39+44+45+101 -bs-re-out -impl /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.ast errored, with the following output:

File "", line 1:
Error: I/O error: : No such file or directory
and then tried to load the cmt, but got
Failed to load /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.cmt as a cmt w/ ocaml version 402, error: /Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/Component2-ReactTemplate.cmt

@jaredly
Copy link
Owner

jaredly commented Aug 25, 2019

@bobzhang What do you mean "-impl is an internal option, not needed anymore"? -impl is a standard ocamlc option -- are you dropping compatibility with ocamlc arguments?
-impl is the standard way for getting ocamlc/bsc to compile a file that contains a binary ast.
I mean I guess I could lie and use the .ml suffix, but -impl seems much clearer.

@bobzhang
Copy link
Contributor

bobzhang commented Aug 25, 2019

I just checked bsc -impl xx.ml still works. Note we will try to make it compatible with ocamlc(e,g, we added -e flag recently), but does not provide such guarantee. What's Component2-ReactTemplate.ast?

@jaredly
Copy link
Owner

jaredly commented Aug 25, 2019

ermmm bsc -impl xx.ml now echos the .js file to stdout? That's a major change of behavior. Did something change about the way bsc looks for dependency files or something that could be producing this error?

@bobzhang
Copy link
Contributor

Indeed, bsc used to be an internal command that we recently made it useful for single file toying around (https://bucklescript.github.io/blog/2019/08/12/release-5-10-0)
What would you need for editor integration, could we provide this directly instead of relying on low level API? Note the cmt file is always generated and up to date after running bsb. You can query the command line using bsb -- -t commands target, such API is also easier to maintain on our side

@jaredly
Copy link
Owner

jaredly commented Aug 25, 2019

So the place where I need to use bsc directly is for "as you type" analysis -- I need to get type information without updating the file in the file system where bsb expects it.
And it worked perfectly when bsc acted the same as ocamlc, I could use the same code for both. Now that bsc is being treated as an internal/unstable api, that makes my job rather harder.

@bobzhang
Copy link
Contributor

where I need to use bsc directly is for "as you type" analysis

Would you give me a detail what you want to achieve, we can provide even better integration in most cases. From what I can tell, rls try to assemble command line args from .merlin which could be less consistent. The thing is that the merlin specification is not complete and does not understand the whole project structure, bsb understand the whole project and can provide all you need in a consistent way (consistent with the real build flags)

Now that bsc is being treated as an internal/unstable api

bsc was indeed internal stuff, until in this release, we make it public so that people can toy around without setting up a project

@bobzhang
Copy link
Contributor

hi @jaredly let me know what I can help here.
Treating bsc different from ocamlc would bring some extra work, but in my opinion it is worth it, it would bring more consistent experience to users.
For example, we are probably going to generate multiple .merlin per directory to support ppx per directory, this may make your support more difficult to assemble the command line args from .merlin file. Also since .merlin is for native, we mimic this behaivor using bsppx, but this is really not needed if rls take the input from bsb directly.
The thing merlin or native toolchain works against ocamlc/ocamlopt is that in native world, there is no enforced build system(dune is popular but not the only one), but it is not the case in bsb, so that we can provide higher level API to authors

jmackie pushed a commit to jmackie/reasonml.nix that referenced this issue Aug 30, 2019
Latest version breaks the reason-language-server.

Revert when jaredly/reason-language-server#320 is fixed.
@TheSpyder
Copy link

@bobzhang how hard would it be to bring back the old bsc behaviour, even if it's in a new executable, until @jaredly (or another contributor) has time to work on this?

@bobzhang
Copy link
Contributor

I checked this was probably due to the change of -impl xx.ast.
Note we already have .ast file generated in the build directory, in the long run, it is best for rls to take advantage of the build system to produce faster/consistent editor service.
I will check if we can provide a quick fix for the short time

@TheSpyder
Copy link

Thanks for looking into it 😁

As far as I can tell, the key difference between RLS and BSB is that RLS provides feedback before the file is saved (a feature I believe merlin also supports?). For that to work it’s saving a temporary file and running bsc directly.

It might be difficult to replicate that with BSB.

@bobzhang
Copy link
Contributor

bobzhang commented Sep 16, 2019

@jaredly it seems xx.ast is not produced correct.
The header format of xx.ast is -- Magic number + file name + Marshal of ast, here xx.ast has empty file name.

utop # let ic, x = Pparse.open_and_check_magic "/Users/hongbozhang/git/reason-language-server/examples/bs-5.1.0/node_modules/.lsp/C
omponent2-ReactTemplate.ast" Config.ast_impl_magic_number;;
val ic : in_channel = <abstr>
val x : bool = true
─( 15:43:22 )─< command 4 >─────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # (input_value ic : string);;
- : bytes = ""

it may be that refmt does not follow the protocol closely
https://github.com/jaredly/reason-language-server/blob/diagnose-5.1.0/src/analyze/AsYouType.re#L20

@bobzhang
Copy link
Contributor

I made a tentative fix, would anyone confirm it would be fixed in this PR rescript-lang/rescript#3823

@sync
Copy link
Author

sync commented Sep 16, 2019

@bobzhang can confirm this fixes it, amazing thank you

@sync
Copy link
Author

sync commented Sep 16, 2019

But i think it's causing another issue (it's putting another red error at the top of the files pointing to the .js file):

Screen Shot 2019-09-16 at 8 36 28 pm

@sync
Copy link
Author

sync commented Sep 16, 2019

Screen Shot 2019-09-16 at 8 38 30 pm

@sync
Copy link
Author

sync commented Sep 16, 2019

5.0.6 for comparison doesn't have the red squigly at the top

Screen Shot 2019-09-16 at 8 44 53 pm

@bobzhang
Copy link
Contributor

@sync working on this, give me a sec

@bobzhang
Copy link
Contributor

@sync pushed a new commit, can you confirm it is good now

@sync
Copy link
Author

sync commented Sep 16, 2019

trying this now

@sync
Copy link
Author

sync commented Sep 16, 2019

All good can confirm it is working now thank you so much !! Tested in vscode and vim (with coc and lsp)

@jaredly
Copy link
Owner

jaredly commented Sep 16, 2019

Note we already have .ast file generated in the build directory, in the long run, it is best for rls to take advantage of the build system to produce faster/consistent editor service.

@bobzhang the feature at stake is as-you-type compilation, which means the .ast file bucklescript produces doesn't fit :)
Thank you so much for working on this!

@TheSpyder
Copy link

TheSpyder commented Sep 19, 2019

I'm seeing an issue using 5.2.0-dev.2, uncurried functions are marked as errors by RLS (bsb has no issues with them)

ReasonML code:

let foo = (. a) => Js.log(a);
foo(. "hi");

RLS error, highlighting the word foo on the second line:

Error: This expression has type (. 'a) => unit
This is not a function; it cannot be applied.

It also shows Warning 101: Unused BuckleScript attribute: bs but RLS has been giving me those with 5.0.6 for a while in other circumstances. I have been too busy to log an issue about that since it's just a warning; in this case it's probably related.

@bikallem
Copy link

bikallem commented Sep 24, 2019

Not seeing this issue on 5.2.0.
Seeing the issue on [email protected].

@bobzhang
Copy link
Contributor

bobzhang commented Sep 24, 2019 via email

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

6 participants