console.log("%s=%d", "x", 5) prints "%s=%d x 5" instead of "x=5": Console Formatter (format specifiers) not implemented
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 297
- Forks
- 64
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 16
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bytecodealliance/StarlingMonkey
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bytecodealliance/StarlingMonkey#359 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
bytecodealliance/StarlingMonkey#355 ·
Los mantenedores suelen responder en 1 día
-
CryptoKey class should use Finalizable class policyPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
bytecodealliance/StarlingMonkey#343 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
bytecodealliance/StarlingMonkey#357 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
bytecodealliance/StarlingMonkey#356 ·
Los mantenedores suelen responder en 1 día
Todos los issues de bytecodealliance/StarlingMonkey
Issues similares
-
XPM values line with more than one space between numbers raises ValueErrorPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
python-pillow/Pillow#10429 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
containers/bubblewrap#826 ·
Los mantenedores suelen responder en 1 día