gleam-lang/gleam

LSP: Incorrect function argument suggestion

Open

#4 249 ouverte le 15 févr. 2025

Voir sur GitHub
 (3 commentaires) (0 réactions) (0 assignés)Rust (960 forks)batch import
help wanted

Métriques du dépôt

Stars
 (21 417 stars)
Métriques de merge PR
 (Merge moyen 10j 19h) (69 PRs mergées en 30 j)

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

Guide contributeur