Inferred array elements omit Partial evidence applications
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, rust
- 領域
- compilers, testing-qa
調査の方向性
Start in compiler-frontend/checking/src/source/terms/collections.rs, especially array_core in ArrayMode::Infer, then inspect expression-aware instantiation or subtyping and the evidence handling in forms.rs. Reproduce the issue with the described temporary fixture using just t compiler 1790461440 --verbose and the Node assertion. Done means inferred array elements no longer retain an extra Partial dictionary and the runtime coverage passes without removing the #605 abstractions.
索引モデルが issue の本文から書いたものです。
説明
Problem
A runtime regression discovered while independently reviewing #605: inferred array elements retain a dictionary abstraction without applying its evidence. This is distinct from Granite’s duplicate-Partial inline finding on that PR.
Confirmed on PR #605 head ef33df090. The PR is currently open; this report does not claim the regression is present on main or in a released version.
Minimal reproducer
module Main where
data Choice = Chosen Int | Other
fs = [\(Chosen value) -> value]
Iris infers:
fs :: Partial => Array (Choice -> Int)
Against freshly generated output, this Node assertion fails:
import { strictEqual } from "node:assert/strict";
import * as Main from "./output/Main/index.js";
strictEqual(Main.fs({})[0](Main.Chosen(17)), 17);
Expected: 17.
Actual on the PR head:
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected
+ [Function: $closure$1]
- 17
The semantic tree exposes the missing application:
fs = \{partialDict} -> [\{partialDict1} -> \(Chosen value) -> value]
There is one external Partial dictionary, but each array element incorrectly still expects another dictionary before accepting its Choice argument.
Verification and isolation
I created a temporary compiler fixture with the source above and a verify.mjs containing the assertion, then ran:
just t compiler 1790461440 --verbose
- PR head: Node verification fails with the function-versus-17 assertion above.
- With only the six added lines in
compiler-frontend/checking/src/source/terms/forms.rsrestored to their pre-fix version: the identical fixture passes (1 passed, no pending snapshots).
This isolates the regression to the new evidence abstractions interacting with array-element elaboration. The PR head was restored afterward. The temporary investigation fixture was removed; the timestamp above records the executed command, not a fixture currently committed to the repository.
Cause and proposed direction
In compiler-frontend/checking/src/source/terms/collections.rs, array_core in ArrayMode::Infer infers each expression, calls type-only unification::subtype, and retains the original expression. Constraint handling at the type level does not add an EvidenceApplication to that expression.
Before #605, an inferred partial lambda lacked its required abstraction and happened to work in this path. After #605 correctly supplies that abstraction, the array path leaves it unapplied.
Investigate expression-aware instantiation/subtyping for inferred array elements and add compiler-fixture runtime coverage. Do not remove the evidence abstractions from #605: that would restore the original unsafePartial case-section crash.
Reference result from purs 0.15.15
Compiled the exact five-line Main.purs above with the official Linux release of purs 0.15.15, with no library dependencies:
purs --version
# 0.15.15
purs compile Main.purs --output output
Compilation succeeds. Its only warning is MissingTypeDeclaration, reporting the same inferred type:
Partial => Array (Choice -> Int)
Actual generated fs from output/Main/index.js:
var fs = function (dictPartial) {
return [ function (v) {
if (v instanceof Chosen) {
return v.value0;
};
throw new Error("Failed pattern match at Main (line 5, column 7 - line 5, column 31): " + [ v.constructor.name ]);
} ];
};
The array element accepts Choice directly; it has no extra dictionary parameter. Executed with Node.js v22.23.2:
node --input-type=module -e '
import { strictEqual } from "node:assert/strict";
import * as Main from "./output/Main/index.js";
const result = Main.fs({})[0](new Main.Chosen(17));
strictEqual(result, 17);
console.log(result);
'
Actual stdout is 17; exit status is 0. The constructor call uses purs’s own representation (new Main.Chosen(17)), rather than Iris’s Main.Chosen(17), so neither runtime receives a value from the other compiler’s representation.
Investigation: https://ampcode.com/threads/T-01a0df1f-526b-71ab-a932-9dac42222d89
- 主要言語
- Rust
- スター
- 125
- フォーク
- 12
- 平均マージ
- 7時間 34分
- マージ済み PR(30日)
- 89
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
purefunctor/purescript-iris のほかの issue
-
diagnostics enhancement language-server
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
purefunctor/purescript-iris#648 ·
メンテナーはふだん 1 日以内に返信
-
ideas
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
purefunctor/purescript-iris#620 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
purefunctor/purescript-iris#613 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
purefunctor/purescript-iris#560 ·
メンテナーはふだん 1 日以内に返信
-
tooling
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
purefunctor/purescript-iris#507 ·
メンテナーはふだん 1 日以内に返信
purefunctor/purescript-iris の issue をすべて見る
似ている issue
-
area:io kernel-paused needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bherbruck/solvecraft#7854 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
transit-audio/transit#159 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
HakanSeven12/OpenCADStudio#2257 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
priority: low ui
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
storytold/photocraft#9884 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
triage: new type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
Jagalite/superseedr#376 ·
メンテナーはふだん 1 日以内に返信