Skip to content

Upper/lower bound computations in Dart give surprising results #176

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

Open
leafpetersen opened this issue Jan 11, 2019 · 5 comments
Open

Upper/lower bound computations in Dart give surprising results #176

leafpetersen opened this issue Jan 11, 2019 · 5 comments
Labels
least-upper-bound Proposals about improvements of the LUB algorithm state-backlog

Comments

@leafpetersen
Copy link
Member

Tracking issue for a longstanding problem that didn't get well-resolved in Dart 2. Fixing this will be breaking.

For language team reference, some non-public discussion here.

@natebosch
Copy link
Member

Does this issue cover the discussion at dart-lang/sdk#25821 (comment) about removing the LUB computation when there is enough context to type check the two values individually?

@natebosch
Copy link
Member

Also, does it cover the discussion at dart-lang/sdk#19425 (comment) ?

@eernstg
Copy link
Member

eernstg commented Sep 9, 2021

I believe it's fair to say that dart-lang/sdk#19425 is covered: It deals with a case which is now handled by the UP(C<T0, ..., Tn>, C<S0, ..., Sn>) rule.

@eernstg
Copy link
Member

eernstg commented Oct 13, 2021

Note also the following issues on very similar topics:

I created label least-upper-bound to make these proposals visible as a group.

@lrhn
Copy link
Member

lrhn commented Mar 29, 2023

Just to keep coming up with issues, and reminding that it's not just about conditional expressons. All LUBs are dangerous. Consider:

class Foo {}
class _BarBase extends Foo {}

class Bar extends _BarBase {}

class _BazBase extends Foo {}

class Baz extends _BazBase {}

void main () {
  var list = [Bar(), Baz()];
  list.add(Foo());
  print(list.length); 
}

All is well, the LUB of Bar and Baz is Foo.

Then I recognize that _BarBase and _BazBase can be combined and change it to:

class Foo {}
class _BarBazBase extends Foo {}

class Bar extends _BarBazBase {}

class Baz extends _BarBazBase {}

void main () {
  var list = [Bar(), Baz()];
  list.add(Foo()); // Error, cant pass `Foo` to argument expecting `_BarBazBase`.
  print(list.length); 
}

(LUB delenda est!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
least-upper-bound Proposals about improvements of the LUB algorithm state-backlog
Projects
None yet
Development

No branches or pull requests

4 participants