Skip to content

Wrong type inference with record on expression evaluation #56859

@FMorschel

Description

@FMorschel

Repro:

void main() {
  foo();
}

void foo() {
  bar({
    for (var i = 0; i < 10; i++) (i,),
  });
}

void bar(Set<(int,)> things) {
  baz(things);
}

int baz(Set<(int,)> things) => things.fold(0, (a, b) => a + b.$1);

Add a breakpoint inside bar.
Now add baz(things) to watch or run this on the debug console and see:

evaluateInFrame: (113) Expression compilation error
org-dartlang-debug:synthetic_debug_expression:1:5: Error: The argument type '_Set<dynamic>' can't be assigned to the parameter type 'Set<(int)>'.
 - '_Set' is from 'dart:_compact_hash'.
 - 'Set' is from 'dart:core'.
baz(things)
    ^

If you change the expression to baz(things.cast()) it works.

I did some experimenting and if you remove the Record from this and use only int the expression is evaluated correctly.

Could this be related to the problems we talked about in this issue that surround Records not having an element?


CC: @DanTup, @bwilkerson

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.cfe-expression-compilationIssues related to expression compilation in the CFElegacy-area-front-endLegacy: Use area-dart-model instead.vm-debugger

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions