LSP type inlay hint prefers initializer type over inherited redefinition typing

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

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

@devin-ai-integration がすでに取り組んでいます。

2026年11月16日 から。

  • #2333 @devin-ai-integration による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, vscode
領域
devtools

調査の方向性

Start with inferredType in internal/workspace/model/editor_facts.go, which calls sem.ExprResultType before sem.DeclaredFeatureTypes, so the string literal's String type wins over the inherited Label typing. Reproduce with the Example package in the issue via an inlay-hint request for the whole document. Done when the hint after redefines name reflects the inherited Label typing or clearly separates the initializer type from the feature's effective type, with a test covering that case.

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

説明

bug
What happened, and what I expected instead

For an attribute that redefines a feature typed by a custom String subtype, the language server displays : String with tooltip inferred type ScalarValues::String. This looks like the type of the feature, but it is the type of the initializer expression and omits the more specific typing inherited through the redefinition.

Expected: the hint should account for the inherited Label typing, or clearly distinguish the initializer's expression type from the feature's effective typing. This report concerns the misleading inlay hint; it does not claim that the underlying semantic model loses the inherited typing or that assignment compatibility is necessarily validated incorrectly.

Reproduction

Open this standalone model and enable inferred-type inlay hints:

package Example {
    attribute def Label :> ScalarValues::String;
    attribute def Record {
        attribute name : Label;
    }
    attribute example : Record {
        attribute redefines name = "example";
    }
}

The hint after redefines name is : String, rather than reflecting the inherited Label typing.

Independently reproduced against sysml-lsp v0.12.1 using a fresh stdio LSP process with -no-record-cache: send initialize, initialized, textDocument/didOpen with the model above, and textDocument/inlayHint for the whole document. No model file needs to be written.

The server published an empty diagnostic list and returned:

[
  {
    "position": { "line": 6, "character": 32 },
    "label": ": String",
    "kind": 1,
    "tooltip": "inferred type ScalarValues::String",
    "paddingLeft": true
  }
]
Suspected cause

In internal/workspace/model/editor_facts.go, inferredType first calls sem.ExprResultType(scope, usage.Value) and only consults sem.DeclaredFeatureTypes(sym) if that returns nil. A string literal therefore supplies String before inherited/redefined feature typing can inform the hint.

Source checked at the installed extension's commit:
https://github.com/Open-MBEE/OpenSysML/blob/ddc5b7a632/internal/workspace/model/editor_facts.go

Version

Original editor observation: VS Code extension open-mbee.opensysml-sysml, version 0.12.2-nightly-20261109-ddc5b7a632.

Independent LSP reproduction:

sysml-lsp v0.12.1
  Commit:     b2f0e9b802a334369da94312c35cefbd8726d3bf
  Build time: 2026-11-06_03:25:57
  Go version: go1.27.3
Surface

Language server (sysml-lsp) / VS Code extension

Platform

Linux, VS Code Remote environment.

主要言語
Go
スター
59
フォーク
20
平均マージ
10時間 23分
マージ済み PR(30日)
897

環境構築

はじめの一歩

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

Open-MBEE/OpenSysML のほかの issue

Open-MBEE/OpenSysML の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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