ocaml-lsp icon indicating copy to clipboard operation
ocaml-lsp copied to clipboard

How to troubleshoot `destruct` when "No code actions for 'destruct' available"?

Open mbarbin opened this issue 1 year ago • 4 comments

Hi!

I notice the recent post about the amazing destruct on ocaml discuss, and I am excited to try it out.

When I type Alt+d on a pattern '_' in vscode, I see a message saying: "No code actions for 'destruct' available". This is from within an editor, while a dune build @all @runtest -w is running in that repo, and reached a Success, waiting for filesystem changes... state.

Here are some info about the environment under which this happens:

ocaml 5.2.0 dune 3.15.3 ocaml-lsp-server 1.18.0~5.2preview merlin 5.0-502

Could you give me some pointers as to how to troubleshoot my installation, or things I need to upgrade, enable, configure, etc.

Thank you!

mbarbin avatar Jun 06 '24 09:06 mbarbin

Not a maintainer, but I believe your installation is fine. That message simply warns you that destruct can't infer any constructor from your pattern, or that it is already exhaustive. Maybe share the code snippet with the pattern you tried running destruct on?

Here's an example image

dalps avatar Jun 06 '24 21:06 dalps

Hi, and thanks for your help! That's helpful for you to confirm the installation is fine. This prompted me to try further.

I'm trying with simple cases first, just to see if things are working.

let _f (a : int option) = match a with _ -> ()
;;

no-code-actions-for-destruct

However, I am now noticing that the clickable More Actions menu proposes actions that do work (Destruct-line, and Destruct).

more-actions

This narrows it down to the use of the shortcut Alt + d, perhaps.

Back to my question, are there some logs I could try to access ? (vscode+ocaml-platform newbie here, relatively recently switch from another editor !!!)

Thank you

mbarbin avatar Jun 06 '24 21:06 mbarbin

Strange, I can't replicate the behavior shown by your screenshots; on my end Alt + d works well on your example code, however I don't get those two actions in the More actions menu... quirky, but I can't help much further in that regard.

VS Code has an "Output" panel wherein you can inspect messages sent by extensions, the OCaml platform docs explains how to enable them for ocaml-lsp.

dalps avatar Jun 06 '24 22:06 dalps

Turns out I was using an older version of ocaml-lsp. After updating my installation to ocaml-lsp-server 1.18.0~5.2preview, the destruct option is no longer available through the Alt + d shortcut.

dalps avatar Jun 11 '24 10:06 dalps

@voodoos now we can close this.

smorimoto avatar Mar 14 '25 13:03 smorimoto

Thank you!

mbarbin avatar Mar 14 '25 13:03 mbarbin