microts: compiled-model analysis crashes with "undefined is not an object (evaluating 'ast.statements')" when the model file is not in the TypeScript program
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 66/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- bun, typescript
- 領域
- compilers
調査の方向性
Reproduce with the --output (guest) build first, then read microts/compiler/aot-model-view.ts:12 (the realpathSync model lookup) against microts/compiler/aot-solid-frontend.ts:89 (createTypeEnvironment), which builds the program from view files. Add a temporary log of the requested path and env.program.getSourceFile(file) to confirm the two mismatches described (missing from program in A, /tmp vs /private/tmp in B), then fix all three dereference sites: aot-model-frontend.ts:827, :854, :1068. Done looks like both repros compiling, or a located diagnostic instead of the ast.statements TypeError.
索引モデルが issue の本文から書いたものです。
説明
Version
PocketJS v0.17.0 (83c6cac9, current main). macOS 27.2 arm64 (APFS, /tmp is a symlink to private/tmp), Bun 1.4.2.
Repro
Two triggers, one crash site.
pocket.host.json, pocket.host.config.ts, main.tsx, app.ts
{
"format": "pocket-host/2",
"id": "repro-esp32s3",
"platform": "esp-idf",
"form": "takeover",
"cadences": [30],
"display": {
"logicalViewports": [[240, 240]],
"presentations": ["native"],
"rasterDensity": 1,
"animation": "repaint"
},
"panel": { "primary": [240, 240] },
"capabilities": ["input.buttons", "text.glyphs.baked"]
}
// pocket.host.config.ts
import { defineHostConfig } from "@pocketjs/framework/host-config";
export default defineHostConfig({
host: "./pocket.host.json",
app: {
id: "dev.example.repro",
title: "Repro",
version: "0.1.0",
entry: "main.tsx",
output: "repro",
framework: "solid",
viewport: { logical: [240, 240], presentation: "native" },
features: ["input.buttons", "text.glyphs.baked"],
aot: true,
model: "compiled",
},
});
// main.tsx
import { mount } from "@pocketjs/framework/solid";
import App from "./app.tsx";
mount(() => <App />);
// app.ts
import { createSignal } from "solid-js";
import type { i32 } from "@pocketjs/framework/solid/std";
export const [count, setCount] = createSignal<i32>(0);
A: the root view does not import its model
// app.tsx
import { Text, View } from "@pocketjs/framework/solid/components";
export default function App() {
return (
<View class="w-full h-full p-4 bg-slate-100">
<Text class="text-lg text-slate-900">Hello</Text>
</View>
);
}
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --aot --out gen
B: the project is reached through a symlink
The same files, with an app.tsx that imports ./app (import { count, setCount } from "./app"; and uses both), in /tmp/repro with node_modules resolvable from there. Run from another directory:
bun $POCKETJS/tools/pocket.ts compile --config /tmp/repro/pocket.host.config.ts --aot --out /tmp/repro/gen
Run from inside the directory with --config pocket.host.config.ts, the same project compiles: process.cwd() is already /private/tmp/repro.
Actual
A and B, in both --aot and guest (--output) builds:
PocketJS: undefined is not an object (evaluating 'ast.statements')
Stack from the guest build:
TypeError: undefined is not an object (evaluating 'ast.statements')
at analyzeModel (microts/compiler/aot-model-frontend.ts:828:24)
at analyzeViewModel (microts/compiler/aot-model-view.ts:13:15)
at analyzeSolidAot (microts/compiler/aot-solid-frontend.ts:91:17)
at checkSolidAotGraph (microts/compiler/aot-solid-browser.ts:39:137)
at getSolidAotProgram (microts/compiler/aot-solid-browser.ts:84:20)
at transformFile (framework/compiler/jsx-plugin.ts:554:69)
at walk (tools/build.ts:309:21)
Expected
- A: the model is analyzed (a root model can hold state and tasks the view does not read), or the compiler reports a located diagnostic such as "app.tsx does not import its model app.ts".
- B: the project compiles as it does from its canonical path.
Cause
The TypeScript program holds the view files and the modules they import (createTypeEnvironment(files, entry), microts/compiler/aot-solid-frontend.ts:89). analyzeViewModel selects the model by file-system lookup and canonicalizes it with realpathSync (microts/compiler/aot-model-view.ts:12). analyzeModel then reads env.program.getSourceFile(file)! (microts/compiler/aot-model-frontend.ts:827) and dereferences it.
- In A, no view imports
app.ts, so it is not in the program. - In B, the program holds
/tmp/repro/app.tsand the lookup asks for/private/tmp/repro/app.ts.
aot-model-frontend.ts:854 and :1068 read getSourceFile(file)! the same way.
Workaround
- A: import a value from the model in the view and use it.
- B: compile from the canonical path (
cd "$(pwd -P)", or pass a--configpath without symlinks).
- 主要言語
- TypeScript
- スター
- 1.6k
- フォーク
- 88
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pocket-stack/pocketjs のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
pocket-stack/pocketjs#729 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pocket-stack/pocketjs#725 ·
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
pocket-stack/pocketjs#724 ·
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
pocket-stack/pocketjs#728 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
pocket-stack/pocketjs#727 ·
pocket-stack/pocketjs の issue をすべて見る
似ている issue
-
kind:defect
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
mux-labs/mux-frontend#1240 ·
メンテナーはふだん 1 日以内に返信
-
area: agents-mcp priority: normal
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
Wait for the IDS correction dialog to settle in the stale-audit test対応中かも @louistrue が今日担当しました。 オープンready
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Hono path parameters with a regex pattern keep the pattern in the OpenAPI path対応中かも @0z5a が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
cloudflare/chanfana#400 ·
メンテナーはふだん 1 日以内に返信