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

Analyzer and front end disagree on whether to report an error #48955

Open
stereotype441 opened this issue May 4, 2022 · 0 comments
Open

Analyzer and front end disagree on whether to report an error #48955

stereotype441 opened this issue May 4, 2022 · 0 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).

Comments

@stereotype441
Copy link
Member

I'm opening this bug as a placeholder while I investigate further. For now I'm assigning to area-language since I don't know whether the analyzer or front end is misbehaving. When I know more, I'll update the bug description and reassign to the appropriate area.

The analyzer and the front end disagree as to whether the following code (from #48952) is erroneous:

typedef SettingOrFunc = int? Function<T>(ContainsValue<T> tag);

class ContainsValue<T> {
  final T val;
  ContainsValue(this.val);
}

class UsesSetting {
  final SettingOrFunc? setting;
  UsesSetting({this.setting});

  /// Do stuff with wrappedValue here,
  /// for my project, if wrappedValue is/returns null,
  /// default values are used otherwise uses the wrappedValue's return.
}

void main(List<String> args) {
  UsesSetting(
    setting: <num>(t) => t.val == 50 ? 0 : null, // is fine
  );
  UsesSetting(
    setting: <num>(t) => t.val < 50 ? 0 : null, // throws analysis error:
                                                // The operator '<' isn't defined for the type 'Object'.
                                                // Try defining the operator '<'. dart(undefined_operator)
  );
}
@stereotype441 stereotype441 added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label May 4, 2022
@stereotype441 stereotype441 self-assigned this May 4, 2022
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).
Projects
None yet
Development

No branches or pull requests

1 participant