gleam-lang/gleam

LSP: Incorrect function argument suggestion

Open

#4,249 opened on Feb 15, 2025

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Rust (21,417 stars) (960 forks)batch import
help wanted

Description

  • Steps and code to reproduce the problem

LSP suggests arguments to effect.from but I'd expect arguments to request.set_header. Even no suggestions at all would be better than incorrect suggestion.

Code to reproduce:

import gleam/fetch
import gleam/http
import gleam/http/request
import gleam/io
import gleam/javascript/promise
import gleam/json
import lustre/effect.{type Effect}

pub type Msg {
  OnAssocResp(Nil)
}

fn assoc_post(note_id: Int, context_name: String) -> Effect(Msg) {
  let url = "http://localhost:8080/assoc"
  let js =
    json.object([
      #("note_id", json.int(note_id)),
      #("context_name", json.string(context_name)),
    ])

  use dispatch <- effect.from
  let assert Ok(req) = request.to(url)
  let req = request.set_method(req, http.Post)
  let req = request.set_header(
  let req = request.set_body(req, json.to_string(js))
  fetch.send(req)
  |> promise.map(fn(_) { OnAssocResp(Nil) })
  |> promise.tap(dispatch)
  Nil
}

pub fn main() {
  io.println("Hello from foo!")
}
  • Versions for Gleam, OS, the runtime and any other software used gleam 1.8.1

Contributor guide