Skip to content

[DDC] Canonicalizes two distinct functions to the same object #46568

Closed
@eernstg

Description

@eernstg

Consider the following program:

X? genericTopLevelFunction<X>() {
  print('genericTopLevelFunction');
  return null;
}

class A {
  static X? genericStaticMethod<X>() {
    print('genericStaticMethod');
    return null;
  }
}

const int? Function() cIntTopLevelFunction1 = genericTopLevelFunction;
const int? Function() cIntStaticMethod1 = A.genericStaticMethod;

void main() {
  if (identical(cIntTopLevelFunction1, cIntStaticMethod1)) throw 0;
}

With the configuration architecture: x64, compiler: dartdevc, mode: release, runtime: chrome, system: linux, timeout: 960, host-checked in commit ba5611a, this program throws, i.e., the invocation of identical evaluates to true.

Unless something very surprising is going on here (with identical), this implies that the two tearoffs denote the same object at run time. Clearly, this should not be the case for two functions with different behavior.

Metadata

Metadata

Assignees

Labels

area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)web-dev-compiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions