Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[cling] lambdas have unexpected semantics in the interactive interpreter

オープン
#22,624 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@devajithvs がすでに取り組んでいます。

2026年6月16日 から。

評価

この issue はまだ評価されていません。

説明

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

主要言語
C++
スター
3.3k
フォーク
1.6k
平均マージ
2日 17時間
マージ済み PR(30日)
211

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

root-project/root のほかの issue

root-project/root の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。