Skip to content

Expression compilation inside extension sometimes has #this not as the first parameter (resulting in bad stuff) #61502

@jensjoha

Description

@jensjoha

Say I have this code:

import 'dart:developer';

extension on String {
  List<String> get foo {
    List<String> result = [];
    int offset = indexOf(':') + 1;
    void bar() {
      debugger();
      while (offset < length) {
        if (codeUnitAt(offset) != 32) {
          return;
        }
        offset++;
      }
    }

    bar();
    result.add("$offset");
    offset++;
    return result;
  }
}

void main(List<String> args) {
  print(args[0].foo);
}

and say I run it like

dart --enable-vm-service t.dart hello

If I open up observatory (ehh, not built in any more but still possible) and go to the debugger (that is now paused) it says

<library>	t.dart
offset	0
#this	'hello'

Notice how #this is below offset.

Trying to evaluate offset it will say hello:

$ p offset
= 'hello'

which clearly isn't right.

Trying to run as

dart -DDFE_VERBOSE=true --enable-vm-service t.dart hello

confirms the wrong order too:

[offset, #this]

I've tried with current HEAD, Dart 3.8.0, Dart 3.7.2, Dart 3.6.2, Dart 3.5.4, Dart 3.3 and Dart 2.7.2 and they all behave the same.

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triagedIssue has been triaged by sub teamtype-enhancementA request for a change that isn't a bugvm-observatory-debugger

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions