Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[cling] lambdas have unexpected semantics in the interactive interpreter

Abierto
#22,624 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@devajithvs ya está trabajando en esto.

Desde el 16/6/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

improvement in:Cling
Explain what you would like to see improved and how.

Running the following lines in the interpreter (line by line, not as a macro) produces an unexpected result (as in, a result that doesn't logically follow from surface knowledge of how the interpreter treats line-by-line statements + how C++ behaves):

int foo = 1
auto f = [=] { return foo; }
f()
foo = 2
f()

Expected output:

(int) 1
(int) 1

Actual output:

ROOT_prompt_1:1:1: warning: captures will be by reference, not copy
auto f = [=]{return foo;}
^
(int) 1
(int) 2

The same happens if we use explicit capture by name: auto f = [foo=foo] { return foo; }.

This is unexpected because, even knowing the variable declarations will be hoisted to the global scope, in regular C++:

  • one cannot declare a global capture-default lambda; (should not compile)
  • one can declare a global capture-by-named-copy lambda ([foo=foo]) and it works as expected (captures the value, not the reference).

NOTE: running the same code as a macro works as expected.

ROOT version

master

Installation method

any

Operating system

Linux (likely any)

Additional context

No response

Lenguaje dominante
C++
Estrellas
3.3k
Forks
1.6k
Merge medio
2 d 17 h
PR fusionados (30 d)
188

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 root-project/root

Todos los issues de root-project/root

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.