new Function interpreter: with statement unsupported (breaks lodash _.template defaults)

Abierto
#13,962 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
46/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust, typescript

Línea de trabajo

Start with the runtime interpreter for new Function bodies introduced in #6559 and trace how it parses and handles statement constructs. Reproduce the supplied with (obj) example and compare it with the working literal body. Done means the runtime-built example prints 42, while the reported lodash template case no longer fails.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug package-audit

The runtime interpreter for new Function / Function(...) bodies (#6559) rejects with statements:

const body = ["with (obj) {", "  return a + 1;", "}"].join(process.argv.length > 99 ? "x" : "\n");
console.log(Function("obj", body)({ a: 41 }));
  • Node: prints 42
  • Perry (ced22982): TypeError: perry runtime interpreter (new Function, #6559): unsupported construct: with statement

A literal body compiled ahead of time works; only runtime-built bodies hit the interpreter.

Impact: lodash's _.template with default options (no variable setting) builds its render function as Function(... "with (obj) { ... }" ...), so it fails in lodash compiled from source. With { variable: 'd' }, which generates no with, it works. Other template engines that use the same with pattern (underscore templates, ejs without _with: false) would hit this too.

Found while probing removal of the native lodash shim.

Lenguaje dominante
Rust
Estrellas
4.9k
Forks
166
Merge medio
3 h 46 min
PR fusionados (30 d)
891

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PerryTS/perry

Todos los issues de PerryTS/perry

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.