Completion offers nothing for an array element after a spread

オープン
#9,183 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
ocaml
領域
devtools

調査の方向性

The bug is in traverse_expr in analysis/src/completion_expressions.ml, which handles Pexp_array and dict literals but has no case for the Pexp_spread node. Start by reading the Pexp_array branch to see how element positions are traversed, then add handling so an array spread keeps the expected element type. Done when completion after [...base, ] offers First and Second, matching [First, ], and the untyped File module fallback no longer appears.

索引モデルが issue の本文から書いたものです。

説明

Found by differential semantic drift analysis from b123b7c3 to c10223e8.

What is broken

type kind = First | Second
let base: array<kind> = [First]
let ys: array<kind> = [First, ]
//                            ^com First, Second
let ys2: array<kind> = [...base, ]
//                               ^com nothing

At c10223e8, completion at the second position returns no items; at b123b7c3 it returned a single bogus [] item of type 'a (from Primitive_array.spread). [...base, Fi] falls back to untyped completion (offering First and the module File). The expected items are the same as for [First, ].

traverse_expr handles Pexp_array and dict literals, including dict spreads, but has no case for the Pexp_spread node that #8905 introduced for array and list literals with spreads.

Possible cause (speculation only)

Before #8905 a spread literal was a call to Primitive_array.spread, which completion treated as a function argument; the new node falls into the default case.

🤖 Generated with Claude Code

主要言語
OCaml
スター
7.5k
フォーク
484
平均マージ
17時間 2分
マージ済み PR(30日)
249

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rescript-lang/rescript のほかの issue

rescript-lang/rescript の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。