Stream: beginners

Topic: possible roc-ls bug?


view this post on Zulip Oli (Dec 13 2023 at 00:35):

Hi, I'm trying out Roc (looks very cool!) and I think I found a bug in roc-ls, but just wanted to post here before making an issue since I'm very unsure.

I wrote a function like this:

f = \{field1, field2} -> {}

And when I hovered over it, in my editor (neovim with builtin lsp), it looked like it returned the following type:

{ field1 : , field2 : * } -> {}

...which doesn't look right :thinking:

I did some digging and found that roc-ls is sending the following response to my textDocument/hover request:

{
    contents: "{ field1 : *, field2 : * }* -> {}",
    range: {
        end: {
            character: 1,
            line: 9
        },
        start: {
            character: 0,
            line: 9
        }
    }
}

This includes the correct type of my function, which made me think that roc-ls was fine and the problem was with neovim's lsp. But then I checked the lsp specification for textDocument/hover, and I see that the language server is supposed to return an object of the form:

/**
 * The result of a hover request.
 */
export interface Hover {
    /**
     * The hover's content
     */
    contents: MarkedString | MarkedString[] | MarkupContent;

    /**
     * An optional range is a range inside a text document
     * that is used to visualize a hover, e.g. by changing the background color.
     */
    range?: Range;
}
/**
 * MarkedString can be used to render human readable text. It is either a
 * markdown string or a code-block that provides a language and a code snippet.
 * The language identifier is semantically equal to the optional language
 * identifier in fenced code blocks in GitHub issues.
 *
 * The pair of a language and a value is an equivalent to markdown:
 * ```${language}
 * ${value}
 * ```
 *
 * Note that markdown strings will be sanitized - that means html will be
 * escaped.
 *
 * @deprecated use MarkupContent instead.
 */
type MarkedString = string | { language: string; value: string };

So it looks like roc-ls is returning a MarkedString (which is deprecated), and is assuming that it will be treated as plain text, when in fact it is supposed to be markdown.

Maybe we can return a MarkupContent instead, which supports plaintext as well as markdown?

view this post on Zulip Oli (Dec 13 2023 at 00:36):

Am I crazy? Shall I make an issue?

view this post on Zulip Anton (Dec 13 2023 at 09:36):

Shall I make an issue?

Go for it :)

view this post on Zulip Oli (Dec 13 2023 at 18:18):

Done :)


Last updated: Jul 26 2025 at 12:14 UTC