microts: generated Rust raises unused_assignments and unused_variables warnings
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust, typescript
- Domain
- compilers
Research direction
Start at microts/compiler/aot-model-codegen.ts around lines 251-252, where let mut result_N = Default::default() is emitted before the pop/removeAt arms assign it, and the module-level allow list around line 1211. Then look at tools/aot-compile.ts:161, which writes load_images/load_fonts with an unread ui parameter. Reproduce with the given bun tools/pocket.ts compile --aot command followed by cargo check; done means that crate compiles clean under -D warnings without blanket allows.
Written by the indexing model from the issue text.
Description
Version
PocketJS v0.17.0 (83c6cac9, current main). macOS 27.2 arm64, Bun 1.4.2, Rust 1.98.1.
Repro
A compiled model that calls pop, and an application without images.
pocket.host.json, pocket.host.config.ts, main.tsx
{
"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 { len, pop, push, type i32 } from "@pocketjs/framework/solid/std";
export const [size, setSize] = createSignal<i32>(0);
let stack: i32[] = [1, 2, 3];
export function press(): void {
const top = pop(stack);
push(stack, top);
setSize(len(stack));
}
// app.tsx
import { Text, View } from "@pocketjs/framework/solid/components";
import { press, size } from "./app";
export default function App() {
return (
<View class="w-full h-full p-4 bg-slate-100" focusable onPress={() => press()}>
<Text class="text-lg text-slate-900">{size()}</Text>
</View>
);
}
# harness/Cargo.toml
[package]
name = "aot-warnings"
version = "0.0.0"
edition = "2021"
[dependencies]
microts = { path = "<pocketjs>/engine/microts-runtime" }
[workspace]
// harness/src/lib.rs
#![no_std]
extern crate alloc;
include!("../../gen/include.rs");
pub use generated::*;
pub fn mount(ui: &mut microts::Ui) {
load_fonts(ui);
load_images(ui);
}
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --aot --out gen
(cd harness && cargo check)
Actual
warning: value assigned to `result_0` is never read
--> src/../../gen/app_model.rs:65:41
|
65 | let mut result_0: i32 = Default::default();
| ^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used
66 | result_0 = self.v_2.pop().unwrap_or_else(|| Default::default());
| --------------------------------------------------------------- `result_0` is overwritten here before the previous value is read
warning: unused variable: `ui`
--> src/../../gen/include.rs:12:16
|
12 | fn load_images(ui: &mut microts::Ui) {
| ^^ help: if this is intentional, prefix it with an underscore: `_ui`
A crate built with -D warnings fails on them.
Expected
Generated code compiles without warnings.
Cause
microts/compiler/aot-model-codegen.ts:251–252declareslet mut result_N = Default::default()before thepopandremoveAtarms assign it. The model module's#![allow(…)]list (aot-model-codegen.ts:1211) does not includeunused_assignments.tools/aot-compile.ts:161writesload_images(andload_fonts) with auiparameter that an application without images (or fonts) never reads; the functions carry#[allow(dead_code)]only.
Workaround
#![allow(unused_assignments, unused_variables)] in the crate that includes include.rs. It also hides these warnings in the crate's own code.
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pocket-stack/pocketjs
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
pocket-stack/pocketjs#729 ·
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 85/100
pocket-stack/pocketjs#724 ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 62/100
pocket-stack/pocketjs#728 ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
pocket-stack/pocketjs#727 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 52/100
pocket-stack/pocketjs#726 ·
All issues in pocket-stack/pocketjs
Similar issues
-
kind:defect
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
mux-labs/mux-frontend#1240 ·
Maintainers usually reply within 1 day
-
area: agents-mcp priority: normal
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Wait for the IDS correction dialog to settle in the stale-audit testPossibly taken @louistrue claimed this today. Openready
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Hono path parameters with a regex pattern keep the pattern in the OpenAPI pathPossibly taken @0z5a claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/chanfana#400 ·
Maintainers usually reply within 1 day