Skip to content

Calling user-defined methods within an if/else block in a lambda causes a failure #82224

@jdconrad

Description

@jdconrad

It appears the "this" pointer doesn't get propagated into sub-scopes within a lambda causing a failure.

Reproduce:

int test1() {
  return 1;
} 

void test(Map params) {
  int i = 0; 
  params.forEach( (k, v) -> {
    if (i == 0) {
      test1()
    } else {
      test1()
    }
  } ) 
} 

test(params)

Error:
no 'this' pointer within static method

Workaround:

Use control-flow logic such as if/else, for, and while to replace the lambda causing an issue.

After #74268, all user functions are instance methods, so the this reference needs to be propagated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions