A functional write to a store path stores the function instead of applying it (W-6)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- compilers
调研方向
从 ref/compile/rt-web.ts 中的 pathWrite 开始,并将任何修改同步到 ref/compile/rt.ts 中的副本。将其与正下方的 guessInto 比较,它已经应用了函数值;让最终的路径赋值在它是函数时应用 v。用示例程序在 ref/compile/rt.ts 上运行编译器,并检查点击帧依次为 add1、add2、add3。
由索引模型根据 Issue 内容生成。
描述
A functional write to a path of a structured source stores the function instead of applying it. 02 W-6 says x := f writes f applied to the slot, and that "a path target applies f to the path's value", so cart.items := items => [...items, 2] should append. The compiler accepts the program and lowers the write to the runtime's path writer, which assigns f itself to cart.items.
Program
export default component App() {
source cart := { items: [1] }
<main>
<button onClick={() => { cart.items := items => [...items, 2] }}>add</button>
<p>{len(cart.items)}</p>
</main>
}
Frames
| instant | action | expected | compiled |
|---|---|---|---|
| 0 | mount | add1 |
add1 |
| 1 | click add |
add2 |
add0 |
| 2 | click add |
add3 |
add0 |
The expected column is the same program written with Solid's setter, setCart((d) => { d.items = ((items) => [...items, 2])(d.items); }), run on the same clicks. The compiled column is the crate's output on ref/compile/rt.ts.
Cause
pathWrite in ref/compile/rt-web.ts (and its copy in rt.ts) ends with o[keys[keys.length - 1]] = v. guessInto, two lines below it, already handles a function: o[last] = typeof v === "function" ? v(o[last]) : v. Doing the same in pathWrite would match W-6. It is the path writer of a plain structured source (path: pathWrite(setStore)) and of an optimistic store's truth (path: pathWrite(setTruth)).
Versions: main at e650b85. The published @reactivescript/runtime 0.3.1 has the same assignment inline in its store writer, so released apps are affected too.
- 主要语言
- TypeScript
- 星标
- 127
- 派生
- 7
- 平均合并
- 15 小时 42 分钟
- 30 天内合并 PR
- 63
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/reactivescript 的其他 Issue
-
Vite front end keeps serving a failed build after the missing/broken imported module is fixed可能已有人在做 @cgaaf 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
solidjs/reactivescript#84 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
solidjs/reactivescript#77 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
solidjs/reactivescript#74 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 62/100
solidjs/reactivescript#97 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
solidjs/reactivescript#83 ·
维护者通常 1 天内回复
查看 solidjs/reactivescript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
GetStream/stream-chat-react#3467 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
vercel-labs/ui#1139 ·
维护者通常 1 天内回复
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bot:ai-assisted component:platform-js status:untriaged
难度 2/5 1-3 小时 新手友好度 82/100
midnightntwrk/platform-js#93 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100