console.log("%s=%d", "x", 5) prints "%s=%d x 5" instead of "x=5": Console Formatter (format specifiers) not implemented
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Read builtins/web/console.cpp, especially console_out and the existing to-source logic, then compare its behavior with the Console Standard Formatter steps cited in the issue. Implement the described formatting for the listed specifiers and run the console tests covering formatted arguments. Done means the reproduction prints the expected formatted output, including consuming the %c argument.
由索引模型根据 Issue 内容生成。
描述
Summary
console.log and friends never apply the Console Standard's Formatter, so %s, %d/%i, %f, %o/%O and %c
are printed literally and the arguments are appended after them. Browsers and node substitute them.
Environment
- StarlingMonkey v0.4.0 release
starling.wasm, wasmtime 50.0.1 (wasmtime run -S http --dir . starling.wasm --legacy-script repro.js). builtins/web/console.cppis unchanged onmain(54b3329b).- Checked on 2026-11-03. Reference: node v26.13.0.
Reproduction
console.log("%s=%d", "x", 5);
console.log("%i|%f", 3.9, "2.5");
console.log("%o and %O", { a: 1 }, [1]);
console.log("%c styled", "color: red");
| StarlingMonkey | expected (node) | |
|---|---|---|
| line 1 | Log: %s=%d x 5 |
x=5 |
| line 2 | Log: %i|%f 3.9 2.5 |
3|2.5 |
| line 3 | Log: %o and %O { a: 1 } [1] |
{ a: 1 } and [ 1 ] |
| line 4 | Log: %c styled color: red |
styled (the %c argument is consumed) |
Spec
Console Standard, Logger, step 5: "Otherwise, perform Printer(logLevel,
Formatter(args))". Formatter replaces the first specifier in the first
argument with the converted next argument and recurses:
%s:%String%(arg)%d/%i:%parseInt%(arg, 10)(NaN for a Symbol)%f:%parseFloat%(arg)(NaN for a Symbol)%o/%O: the argument with object formatting%c: CSS in browsers; runtimes without styling consume the argument and print nothing for it
Printer is implementation-defined, but Formatter is not.
Cause
In builtins/web/console.cpp, console_out converts every argument with the existing to-source logic and joins
them with spaces. Formatter is never applied. (Comments near console.assert/console.trace already mention "a
string without any formatting specifiers".)
Suggested fix
When the first argument is a string and more arguments follow, walk it once, replace each specifier with the
converted next argument (reusing the existing to-source code for %o/%O, dropping the argument for %c), then
append the remaining arguments as today. ComponentizeJS only replaces the final print hook, so it gets the fix
automatically.
- 主要语言
- C
- 星标
- 297
- 派生
- 64
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 16
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bytecodealliance/StarlingMonkey 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
bytecodealliance/StarlingMonkey#359 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
bytecodealliance/StarlingMonkey#355 ·
维护者通常 1 天内回复
-
CryptoKey class should use Finalizable class policy可能已有人在做 @andreiltd 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
bytecodealliance/StarlingMonkey#343 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
bytecodealliance/StarlingMonkey#357 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
bytecodealliance/StarlingMonkey#356 ·
维护者通常 1 天内回复
查看 bytecodealliance/StarlingMonkey 的全部 Issue
相似的 Issue
-
area/docs
难度 1/5 1 小时以内 新手友好度 83/100
Clodmony/starship-coop#72 ·
维护者通常 1 天内回复
-
ospf6d: heap-use-after-free in seqnumber_mismatch()/bad_lsreq() when a neighbor is deleted with events pending可能已有人在做 @lichenlang89 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 61/100
维护者通常 2 天内回复
-
5700模组网络优先级问题未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
severity: low
难度 2/5 1-3 小时 新手友好度 76/100
luainkernel/lunatik#2372 ·
维护者通常 1 天内回复