An inline object type on a parameter or local is emitted as TypeScript text

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

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

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

評価

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

調査の方向性

Start by reading the lowering paths that emit types and object literals for the Dafny and Lean backends, then find the tests covering synthetic names for interface fields and return types. Add regression coverage for the sumA parameter and mk local annotation; the issue is done when both examples either resolve on both backends or produce an lsc error naming the inline type.

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

説明

Problem

SPEC.md says anonymous object types in interface fields and in function return types get synthetic datatype names (SpecEntryDecision, ParseSpecYamlResult). The same type written on a parameter or a local variable gets no name. Both backends emit the TypeScript spelling as a type name, and the generated files do not parse.

Reproduced on upstream main at 36eb31d (LemmaScript 0.6.8).

Reproduction

export function sumA(p: { x: number; y: number }): number {
  return p.x + p.y;
}

export function mk(n: number): number {
  const r: { k: number } = { k: n };
  return r.k;
}

lsc gen --backend=dafny emits:

type { x: number; y: number }(==)

function sumA(p: { x: number; y: number }): int
{
  (p.x + p.y)
}

function mk(n: int): int
{
  var r := (n);
  r.k
}

dafny resolve stops at the first line with invalid Ident. mk also lowers the record literal to (n), which has no field k.

lsc gen --backend=lean emits opaque { x: number; y: number } : Type and def sumA (p : { x: number; y: number }) : Int, and lowers the literal to let r := { k := n }.

A named alias, type Pt = { x: number; y: number }, works in the parameter position.

Expected

Either the parameter and local positions get synthetic names, as interface fields and return types do (for example SumAP and MkR), or lsc rejects an inline object type in those positions with a message that suggests a named alias. Both backends fail loudly today, so no false proof results; the cost is valid TypeScript that does not compile and an error message that points at generated text.

Acceptance criteria

  • sumA and mk above either generate code that resolves on both backends or are rejected by lsc with an error naming the inline type.
  • A regression test covers an inline object type on a parameter and on a local annotation.
主要言語
TypeScript
スター
113
フォーク
13
平均マージ
15時間 35分
マージ済み PR(30日)
56

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

midspiral/LemmaScript のほかの issue

midspiral/LemmaScript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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