Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Не видит содержимое текущего класса из короткой лямбды, если она захватывает локальную переменную и вызывает метод расширения #3078

Open
SunSerega opened this issue Apr 3, 2024 · 1 comment

Comments

@SunSerega
Copy link
Contributor

var res := 0;

// Обязательно отдельная подпрограмма в которую передаётся лямбда
// Если присваивать лямбду переменной - не воспроизведётся
procedure p1(a: ()->()) := a();

type t0 = class end;

// Обязательно p2 - extensionmethod
// С обычным методом не воспроизведётся
procedure p2(self: t0; x: byte); extensionmethod := res += 1;

type
  t1 = class
    o: t0;
    
    procedure p3;
    begin
      // Обязательно захватить локальную переменную
      var x := default(byte);
      
      // Обязательно короткая лямбда
      // Если сделать ей тело "begin-end" - не воспроизводится
      
      // OK
      p1(()->self.o.p2(x));
      //Ошибка: Неизвестное имя 'o'
      p1(()->     o.p2(x));
      
    end;
    
  end;
  
begin
  t1.Create.p3;
  Assert(res=2);
end.
@SunSerega
Copy link
Contributor Author

При чём раньше и в лямбдах с телом begin-end воспроизводилось.
Но в какой то момент перестало и теперь только короткие сломаны.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant