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

Wrong type inference with record on expression evaluation #56859

Open
FMorschel opened this issue Oct 5, 2024 · 4 comments
Open

Wrong type inference with record on expression evaluation #56859

FMorschel opened this issue Oct 5, 2024 · 4 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-debugger

Comments

@FMorschel
Copy link
Contributor

FMorschel commented Oct 5, 2024

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

@dart-github-bot
Copy link
Collaborator

Summary: The issue reports incorrect type inference for a Set of Records when evaluating an expression in the debugger. The expression fails to evaluate due to a type mismatch, but works when explicitly casting the Set to the correct type. This behavior suggests a potential issue with type inference for Records in the debugger.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 5, 2024
@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-debugger and removed area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Oct 5, 2024
@FMorschel
Copy link
Contributor Author

Also, could this be related to #56555 in any way?

@a-siva a-siva added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Oct 7, 2024
@a-siva
Copy link
Contributor

a-siva commented Oct 7, 2024

//cc @jensjoha @johnniwinther

@bwilkerson
Copy link
Member

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

No. The referenced issue is strictly limited to the analyzer. The compilation error you're seeing is from the VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-debugger
Projects
None yet
Development

No branches or pull requests

5 participants