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

Implicit method closures aren't canonicalized #3100

Closed
DartBot opened this issue May 17, 2012 · 4 comments
Closed

Implicit method closures aren't canonicalized #3100

DartBot opened this issue May 17, 2012 · 4 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented May 17, 2012

This issue was originally filed by @bp74


What steps will reproduce the problem?

  1. Here is a sample which shows the problem:

class Test1 {
  Test1() {
    document.body.on.click.add(_onBodyClick);
  }
  _onBodyClick(event) {
    print("Test1: onBodyClick");
    document.body.on.click.remove(_onBodyClick);
  }
}

class Test2 {
  EventListener _eventListener;
  Test2() {
    _eventListener = _onBodyClick;
    document.body.on.click.add(_eventListener);
  }
  _onBodyClick(event) {
    print("Test2: onBodyClick");
    document.body.on.click.remove(_eventListener);
  }
}

void main() {
  Test1 test1 = new Test1();
  Test2 test2 = new Test2();
}

What is the expected output? What do you see instead?

Both classes add an EventListener to the click event of the body, but only the "Test2" class can remove the EventListener again. The funny thing is that it is the same in the Dart-VM and in all browsers when compilied to JavaSscript. It almost looks like "works as desingend" but if this is by purpose i think it should be changed.

What version of the product are you using? On what operating system?
Dart Build 7696 32 bit, Windows 7 64 bit

@DartBot
Copy link
Author

DartBot commented May 17, 2012

This comment was originally written by antonm@google.com


Pavel, maybe you check if it's related to your recent change and reassign if not?


Set owner to podivilov@google.com.
Added Area-Dartium, Triaged labels.

@DartBot
Copy link
Author

DartBot commented May 17, 2012

This comment was originally written by podivilov@google.com


The problem here is that implicit method closures aren't canonicalized.

Here is a reduced case:

class A {
  foo() {
    print(bar == bar);
  }
  bar() {}
}

main() {
  new A().foo();
}

which prints false.

Gilad, are there any plans to fix it?


cc @gbracha.
Removed the owner.
Removed Area-Dartium label.
Added Area-Language label.
Changed the title to: "Implicit method closures aren't canonicalized".

@gbracha
Copy link
Contributor

gbracha commented May 17, 2012

We plan to look into this issue pretty soon. And BTW, the bug is a
duplicate,

@gbracha
Copy link
Contributor

gbracha commented May 17, 2012

Set owner to @gbracha.
Added Duplicate label.
Marked as being merged into #144.

@DartBot DartBot added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels May 17, 2012
copybara-service bot pushed a commit that referenced this issue Jul 29, 2022
…2 revisions)

https://dart.googlesource.com/dartdoc/+log/d3b0b724972f..e476b1a11547

2022-07-29 devoncarew@gmail.com remove the height constraint on the search box (#3100)
2022-07-29 srawlins@google.com Bump analyzer to 4.3.1 (#3099)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/dart-doc-dart-sdk
Please CC dart-ecosystem-gardener@grotations.appspotmail.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Dart Documentation Generator: https://github.com/dart-lang/dartdoc/issues
To file a bug in Dart SDK: https://github.com/dart-lang/sdk/issues

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Tbr: dart-ecosystem-gardener@grotations.appspotmail.com
Change-Id: Ic52033c112052bbd2e0eda4f0f2b86786d186e9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253041
Commit-Queue: Nate Bosch <nbosch@google.com>
Commit-Queue: DEPS Autoroller <dart-autoroll@skia-public.iam.gserviceaccount.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

2 participants